assertText (target, pattern) , verifyText (locator, text)- Selenium IDE command

assertText and verifyText both get the text of an element (as defined by the locator) and check if it meets the requirement of the pattern. This works for any element that contains text.

Assert and verify commands are both useful for verifying condition match or not. The difference is that verify command will verify the condition and if it does not match, it will only show an error message in log area and the macro continues to run. With the assert command, if the condition does not match then it will stop remaining macro execution in the selenium IDE software testing tools.

The Ui.Vision RPA Selenium IDE also supports a sourceSearch command. This not an official Selenium IDE command. But as the name suggests, it allows you to do an "assertText" like check directly on the HTML source code instead of the rendered DOM. So you can check/verify/assert text e. g. inside Javascript snippets like Google Analytics.

assertText and verifyText Example

In this short example, we check for the presence of the texts "Welcome" and "Free Web Automation". If "Welcome" is missing, the macro stops since we used assert.

Command Target Pattern/Text
open https://ui.vision/
assertText //*[@id="title"] Welcome
verifyText //*[@id="content"]/div[2]/div/h2[1] Free Web Automation

Works in

Ui.Vision RPA for Chrome Selenium IDE, Ui.Vision RPA for Firefox Selenium IDE, Firefox IDE Classic

Difference between verifyText and verifyTextPresent in Selenium

The "verifyTextPresent" command is not for storing value of any target element, but could be used to verify that specified target text is available anywhere on the page or not. The Ui.Vision RPA IDE does not support verifyTextPresent (and assertTextPresent) because we want to help reduce the zoo of previous IDE commands. In the modern Ui.Vision RPA IDE verifyTextPresent can be easily recreated with storeText plus if.

On the storeTextPresent page you find an example that "simulates" verifyTextPresent by using storeText and then checks if the extracted text is correct. If not, it throws an error. The simulation of verifyTextPresent is actually better than the original: The old verifyTextPresent checks for the presence of the text in the entire page. This can often lead to false positives, and is not generally advised.

Related Demo Macros

DemoStoreEval uses many Asserts

The ready-to-import-and-run source code of all demo macros can be found in the Open-Source RPA software Github repository.

See also

sourceSearch, assertTitle, storeText, Web Automation Extension User Manual, Selenium IDE commands, Classic Firefox Selenium IDE.

Anything wrong or missing on this page? Suggestions?

...then please contact us.

<em>Ui.Vision RPA</em> Selenium IDE for Chrome and Firefox - Web Test Automation

Fresh from the Ui.Vision Forum: The Latest 3 Topics. Join the discussions:

← Meet the Ui.Vision team and users in our forums.