7

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?

John Adam
  • 981
  • 2
  • 7
  • 6
  • More and better choices - https://stackoverflow.com/questions/54242291/robotframework-how-to-check-text-on-page – Dev May 19 '19 at 19:26

2 Answers2

15

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
finspin
  • 4,021
  • 6
  • 38
  • 66
4

If your HTML code is something like: Your div tag and need to find FindMe

<div class="gwt-Label">This FindMe DIV</div>

Then you can find "FindMe" text like:

//div[@class='gwt-Label'][contains(string(),'FindMe')]
Ashish Kamble
  • 2,555
  • 3
  • 21
  • 29
Minal K Sinha
  • 424
  • 2
  • 6