Jay J
Jay J

Reputation: 430

Selenium IDE: How to unselect all options in a multi <SELECT>

I searched for this question and didn't find it, and so am posting it myself. My web page has a multi select like below. All options are selected on page load and with Selenium IDE I'd like to deselect all options and submit the form to ensure a proper error message appears. Any suggestions?

Mavbe embed something in a 'runScript' command?? Can only use IDE here and not Webdriver...

<select id="example" multiple="multiple>
<option selected="selected" value="1">abc</option>
<option selected="selected" value="2">def</option>
<option selected="selected" value="1">ghi</option>
</select>

Upvotes: 1

Views: 1209

Answers (1)

Jay J
Jay J

Reputation: 430

I found a solution to my question and thought I would share. JavaScript can be used:

getEval | var elements = window.document.getElementById("example").options; for(var i = 0; i < elements.length; i++){elements[i].selected = false;}

Upvotes: 1

Related Questions