Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 595
Corina Avatar asked Mar 24 '11 16:03

Corina


1 Answers

*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

like image 105
Dave Hunt Avatar answered Oct 24 '22 01:10

Dave Hunt