Skip to content

How do I validate if a particular option of the drop-down is selected

This example demonstrates validating if a particular option is selected from the drop-down list.

In the solution shown below, you will validate if the option "New Jersey" is selected from the "Select State" drop-down in HICC application using the "verifySelectedLabel" command.

Solution:

# Command Target Value
Select the label 'New Jersey' from the drop-down
1 select //select[@id="dpl_state"] label=New Jersey
Validating if the selected label is "New Jersey"
2 verifySelectedLabel //select[@id="dpl_state"] New Jersey

Tips, Tricks, Gotchas & Best Practices:  

  • To understand how to select an option, click here.
  • As an alternative to validating the selected option, you are encouraged to use either of the commands as given below for each option locator:

Feedback and Knowledge Base