Corina
Corina

Reputation: 1545

Difference between verifyText and verifyTextPresent in Selenium

I'm trying to build a test using Selenium IDE and I want to check that a certain <div> block contains the correct text. What assertion should I use? What is the difference between text and textPresent?

Upvotes: 9

Views: 15294

Answers (1)

Dave Hunt
Dave Hunt

Reputation: 8223

*TextPresent commands check for the presence of the text in the entire page. This can often lead to false positives, and is not generally advised. *Text commands require a locator, and the text of the element located is directly compared. Another advantage is that a failure will give you details of the expected and actual text, whereas the former commands simply return true/false.

You will need a way to locate your <div> element, which is easiest if it has an id attribute. Check the official documentation for locator strategies: http://seleniumhq.org/docs/02_selenium_ide.html#locating-elements

Upvotes: 15

Related Questions