I am trying to set a dropdown value using javascript in selenium IDE, but not able to figure out which selenium command to use.
3 Answers
Selenium IDE command to execute a javascript statement: runScript with the javascript statement as argument.
Example (can be run on Google startpage):
<tr> <td>runScript</td> <td>document.getElementById('searchText').setAttribute("value", "hello");</td> <td></td> </tr>
1 Comment
AlexHalkin
That should be accepted answer based on "Which selenium IDE command should I user to execute a javascript statement" title. However description has mention of dropdown and in this particular case there is no need to execute JS but rather use "select" command mentioned by @houss below.
You can run a script (like above) and set the option you want to "selected".
You can also do it with the selenium select command:
Command: select
Target: id="yourDropDownId"
Value: label="yourOption"
or html source
<tr> <td>select</td> <td>id="yourDropDownId"</td> <td>label="yourOption"</td> </tr>
Comments
Assuming the dropdown has id myDropdown and the value you want to select is valueToSelect, try this:
selenium.select("//select[@id='myDropdown']", "label=valueToSelect");
1 Comment
Ripon Al Wasim
Is it applicable for Selenium IDE?