Selenium “verifySelectOptions”, “verifySelectedLabel” and “verifySelectedIndex” Example

“verifySelectOptions”, “verifySelectedLabel” and “verifySelectedIndex” commands works with drop down list box or multi select list box. Let me explain all of three first and then will see them with example.
Selenium IDE “verifySelectOptions” Command
“verifySelectOptions” command used for verification of list box option values. It will show error message if

defined values not available in list box. You can also use it for verification of option values. If not found match then selenium will return error message in log.

Using “verifySelectedLabel” Command in Selenium
As name suggect, “verifySelectedLabel” command will verify the name of selected label. If not found then selenium will return error message in log.
Selenium “verifySelectedIndex” Command
Every label contains index value in drop down and you can verify correct indexed label selection using “verifySelectedIndex” command. Let we see all three commands with example.

New Test
Command Target Value
open http://only-testing-blog.blogspot.com/2013/09/testing.html
verifySelectOptions name=FromLB USA,Russia,Japan,Mexico,
India,Germany,Italy,Spain,
Malaysia,Greece
verifySelectOptions name=FromLB Russia,Japan,Mexico,
India,Germany,Italy,Spain
select name=FromLB label=Russia
verifySelectedLabel name=FromLB India
verifySelectedLabel name=FromLB Russia
verifySelectedIndex name=FromLB 1
verifySelectedIndex name=FromLB 5

View More verification command examples.

In above example, all three commands inserted 2 times. one with incorrect value and one with correct value.
  • 1st “verifySelectOptions” command will pass because Actual value ‘USA,Russia,Japan,Mexico,India,Germany,Italy,Spain,Malaysia,Greece’ will match with targeted value ‘USA,Russia,Japan,Mexico,India,Germany,Italy,Spain,Malaysia,Greece’.
  • 2nd “verifySelectOptions” command will Fail.
  • 1st “verifySelectedLabel” will be fail because current selected label ‘Russia’ will not match with ‘India’.
  • 2nd “verifySelectedLabel” will be pass.
  • 1st “verifySelectedIndex” command will pass
  • 2nd “verifySelectedIndex” command will be fail because label ‘Russia’ has index = 1.

14 thoughts on “Selenium “verifySelectOptions”, “verifySelectedLabel” and “verifySelectedIndex” Example

  1. 1st "verifySelectOptions" is giving me an error saying did not match with actual value . pls help

  2. Hello,

    How to identify the element "name=FormLB"?
    Which tool should be used to identify UI elements?

    Please reply ASAP.

    Thanks!

  3. I have used the same, but in above example getting error @ verifySelectOptions name=FromLB

    Please help.

    Also please let me know from where i can get the information like which parameters can be used in different commands.
    For ex : In verifySelectOptions command which parameter can be used in target. can we use css, id, xpath etc?

  4. It has error: [error] Actual value 'USA,Russia,Japan,Mexico,India,Germany,Italy,Spain,Malaysia,Greece' did not match 'USA,Russia,Japan,Mexico, India,Germany,Italy,Spain'.Please help me!

  5. It Is Failing because actual values and expected values not matching In 2nd verifySelectOptions. It Is Intensional placed to show you how this command works when values match and not match

Leave a Reply

Your email address will not be published. Required fields are marked *