4

I hope someone is able to help me. I am trying to determine whether or not Selenium IDE can verify that only specific values are present in a drop down list, and should anything else appear within the drop down list it is an error.

For example, using a basic html Single Select drop down list :


<select id="drop_down_list">  
  <option value="Test">Please select...</option>
  <option value="Saab">Saab</option>
  <option value="Mercedes">Mercedes</option>
  <option value="Audi">Audi</option>
</select>

I know I can verify the 'Label' of each selectable value using (for example) :

verifySelectedLabel : //select[@id='drop_down_list'] : Please select...

I know I can verify the 'Value' of each selectable value using (for example):

verifySelectedValue : //select[@id='drop_down_list'] : Test

And I know I can do this for each other selectable value displayed.

But what if for whatever crazy scenario, a Dev decided to add 'Ford' to the drop down list, and he/she did not make anyone aware of this ? My tests would pass as those selectable values which I am expecting are still present.

Is there is a way of verifying that no other values other than those I am expecting are also contained within the drop down list ?

I know there is 'verifyNotSelectedLabel' and 'verifyNotSelectedValue' available for use, and these work perfectly when I can specify the 'Labels' and 'Values' accordingly, but they dont help in this particular scenario.

Fingers crossed someone can help, many thanks in advance to all,

Rabbithell
  • 41
  • 1
  • 3

2 Answers2

3

How about using "verifySelectOptions", this will check all the options in the dropdown exactly how it should appear.

So in case if there is a New value added or some changes in the existing values (like spelling mistake etc) Step will fail.

anil
  • 101
  • 1
  • 5
0

If you right click on the dropdown list while in Selenium-IDE, try choosing verifyTextPresent from the command list. The value will be a text list of all the options in the list strung together(usually with spaces between).

Then if a developer adds a selection(or misspells an existing selection, the step will fail(you could use assertTextPresent if you want the test to stop at that point).

Klendathu

Klendathu
  • 793
  • 1
  • 12
  • 20