I'm currently adding some users and then wanted to check if that one user made it in the dropdown, and if it does make it, then select it.

If it doesn't make it in the dropdown, I want it so spit out an error but don't want it to stop the script, just to go to another part of the script (and continue looping). ]

2 Answers 2


Question is a bit unclear, but I'm checking dropdown lists by xpath expressions.

if this is classic dropdown:

  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>

you can store presence of the option value or text into the variable (function text() is replaced by ".")

storeElementPresent | //select[@id='idOfTheSelectBox']/option[@value='mazda'] | isMazdaValuePresent
storeElementPresent | //select[@id='idOfTheSelectBox']/option[contains(.,'Mazda')] | isMazdaTextPresent

result of stored variables isMazdaValuePresent and isMazdaTextPresent will be true or false.

If this is not a simple selectbox (as usual) this could be little more complicated and I use descendant Xpath expressions for example:

storeElementPresent | //*[@id='mainElement']/descendant::[@id='eachRowElement' and contains(.,'Mazda')] | isMazdaTextPresent

where identification of main element and each row in the element can differ and could be an class or proprietal parameter.

If you have SelBlocks installed, you will be able to make conditions, goto jumps, or cycles according to some array or XML file.


With Selenium, you can use a getEval() with Javascript that returns the innerHTML of the element. Something like this:

 storeEval | window.document.getElementById("id of element").innerHTML | p

This saves the content of the dropdown in the variable p. Alternatively iMacros and Kantu are similar to Selenium IDE but contain dedicated support for extracting values (so you do not need to use Javascript).

  • Okay, I got it pulling the data, how would I compare to the data now, Like go to a label if tomato isn't in the dropdown Commented Jan 20, 2017 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.