How to check if a text is in web page in Robot Framework and Selenium

John Adam picture John Adam · May 17, 2013 · Viewed 23k times · Source

I'm currently creating an automation test for a website and I want to check if a text(s) is in the page. I could use the keyword 'Page should contain' to check; however, I want it to be a little more specific on having it check specifically where the text exist in the page. Is there a way I can have it check if a specific div contains the text?

Answer

finspin picture finspin · May 17, 2013

You can easily do this with a built-in Selenium2Library tags.

For a partial match use this:

Element Should Contain    locator    expected_text

For an exact match use this:

Element Text Should Be    locator    expected_text