I am trying to set a dropdown value using javascript in selenium IDE, but not able to figure out which selenium command to use.
Asked
Active
Viewed 2.0k times
3 Answers
11
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>

AnnTea
- 532
- 7
- 15
-
1That 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. – AlexHalkin Feb 25 '16 at 21:41
1
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>

houss
- 670
- 5
- 9
0
Assuming the dropdown has id myDropdown
and the value you want to select is valueToSelect
, try this:
selenium.select("//select[@id='myDropdown']", "label=valueToSelect");

Vidya
- 29,932
- 7
- 42
- 70