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
?
*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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With