I am using Selenium IDE for the first and has no knowledge of automation scripting. So far i am able to manage using IDE but one issue is I am not able to select a value from dr
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.
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
I tried the below and it worked
Command: Select
Target : element Locator eg : id = card
Value : index=1
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.)
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.
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)