Skip to content

How do I validate the text on UI

This example demonstrates validating the text of an element.

In the solution shown below, you will see that the text in the header section is validated in HICC using "assertText" command. If the command fails the entire execution will stop.

Solution:

# Command Target Value
Validating the header text
1 assertText xpath=(//div[@id='pageheadersection']/h1)[1] Health Insurance Cost Calculator

Tips, Tricks, Gotchas & Best Practices:  

  • As an alternative to above, you are encouraged to use commands as given below based on the requirement:

            1. verifyText -  If the text is not present in the application due to some application issue, the "assertText" command fails and this will stop the execution of the Test Run, If you do not want to stop the execution of the other instructions it is recommended to use this command for verifying the text.

            2. assertTextPresent - If the location of the text changes dynamically then the availability of the text is verified using this command by specifying the text to be verified in the Target field and the Value field is left blank.

           3. verifyTextPresent - This command will work in a similar way as "assertTextPresent" except for it will not stop the execution of the other instructions if the command fails due to application issue.

           4. waitForText - When there is a page loading in the application before the visibility of the text in the User Interface(UI), you can use this command to wait for the text to load in the UI and then verify the text.

           5. waitForTextPresent - When there is a page loading in the application before the visibility of the text in the User Interface and the location of the text in the rendered page is changing dynamically, you can use this command for verifying the text.

Feedback and Knowledge Base