how to select value from a drop down using Selenium IDE

佐手、 提交于 2019-12-04 02:42:09

I tried the below and it worked

Command: Select

Target : element Locator eg : id = card

Value : index=1

General approach is firstly click on the element and then select value from the element.

For Clicking : 1.Command : click 2.target : element locator like xpath/id/class of the element eg. xpath=xpath of the element

For Selecting value: 1.Command : select 2.target : same element locator used for clicking 3.Value : Visible text you want to select / Index (You will get it by inspecting that element)

Use command select(selectLocator, optionLocator), 'selectLocator' is the Id of the drop down from which the value is being selected and the 'optionLocator' is the value being selected.

For eg: say a drop down having Id="//select[@id='type'" with values like 'TypeA, TypeB, TypeC,...'. If you are selecting 'TypeA' from the drop down, your command should go like this:

selenium.select("//select[@id='type']", "label=TypeA");

I hope this will solve your problem.

First get the total number of items in the dropdown. Use getSelectOptions to get an array of options of the select box. Then generate a random integer between 0 (inclusive) and the length of the array (exclusive. Then use select with an index locator to select the randomly chosen option.

Use Command: KeyDown Target:css=input.comboboxname Value: \40

\40 is Down-Arrow Ascii value

then use \13 to make selection in value.(put value for command and Target same.)

a quick and dirty javascript starting point:

<form>
  <select id="mySelect" onchange="myFunction()">
    <option>Apple</option>
    <option>Orange</option>
    <option>Pineapple</option>
    <option>Banana</option>
  </select>
</form>

<p id="demo" onclick="myFunction()" >click me</p>

<script>
function myFunction() {

   document.getElementById("mySelect").selectedIndex = Math.floor((Math.random() * document.getElementById("mySelect").options.length));

}
</script>

and the (somewhat) corresponding seleniumIDE runScript command:

command

runScript

target:

document.getElementById("myDropdown").selectedIndex = Math.floor(Math.random() * (document.getElementById("myDropdown").options.length-1))+1);

The +1 at the end is entirely optional: I've included it to prevent seleniumIDE from selecting the first

Command: Select

Target: Search an Element of the website app. (name, id)

Value: What value/result do you want to see?

Example: As an user I want to select a list of colors of drop down list (Orange, Blue, Red) I want to select Blue color. This is a script.

Command: Select

Target: name=color

Value: Blue

user6150585

Tried below and it worked.

command: waitForNotVisible
target: class=sub-menu
value : index=3

It will work with WaitForVisible command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!