4

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 3

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>
Sign up to request clarification or add additional context in comments.

1 Comment

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.
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>

Comments

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");

1 Comment

Is it applicable for Selenium IDE?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.