I am stuck trying to verify that a drop down box has the required item?
For example following is the drop down box in question
<select id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
I am using Selenium IDE. I am wondering what the following params should be
Command:
Target:
Value:
if i am intending to check if "Audi" is one of the items in the drop down box?
I appreciate any help! Thanks!
You can use verifyText command in selenium IDE to make your your intended element is present or not with given text
Here you go -
Command: verifyText
Target: css=option[value="Audi"]
Value: Audi
Related
I am trying to automate a website to get data. Usually if I know in advance what are the possible value from the drop down list, I can hard code them in my script.
But if I don't know what are the values, is there an elegant way to dynamically obtain the drop down list values?
Working sample from: https://autohotkey.com/boards/viewtopic.php?t=15574
select name="ConnectDTO.EvaluationGroupId" id="ConnectDTO_EvaluationGroupId" style="width: 260px;" required="yes" data-val-number="The field Evaluation Group must be a number." data-val="true"><option value="">Please Select</option>
<option value="4">ccpdmanagement</option>
<option value="7">AM Northern</option>
<option selected="selected" value="3">cwplanning</option>
<option value="1">mnplanning</option>
<option value="2">msplanning</option>
<option value="9">LCC</option>
<option value="6">powerquality2</option>
<option value="8">AM Southern</option>
<option value="5">tcoqueries</option>
</select>
When my script arrived on the page after loadIE(wb), is there a way to "get" the list of selection - such as ccpdmanagement, AM Northern etc...?
I know how to select them once the option is known in advance only.
pwb.document.getElementById("ConnectDTO_EvaluationGroupId").Focus()
pwb.Document.GetelementById("ConnectDTO_EvaluationGroupId").value := "1"
Thanks.
I found a solution here: https://autohotkey.com/boards/viewtopic.php?t=35467
Althought the Author stated he has a problem with the code (stated not work for some reason).
But for my purpose - to retrieve the list of all the drop down list option. It worked fine.
myDropDownList := wb.document.getElementById("your_dropdown_ID")
loop % myDropDownList.length
{
test := myDropDownList[A_Index-1].value
MsgBox %test%
}
I searched for this question and didn't find it, and so am posting it myself. My web page has a multi select like below. All options are selected on page load and with Selenium IDE I'd like to deselect all options and submit the form to ensure a proper error message appears. Any suggestions?
Mavbe embed something in a 'runScript' command?? Can only use IDE here and not Webdriver...
<select id="example" multiple="multiple>
<option selected="selected" value="1">abc</option>
<option selected="selected" value="2">def</option>
<option selected="selected" value="1">ghi</option>
</select>
I found a solution to my question and thought I would share. JavaScript can be used:
getEval | var elements = window.document.getElementById("example").options; for(var i = 0; i < elements.length; i++){elements[i].selected = false;}
i'm using the Jeditable plugin to send request to the server by changing the select box. my problem is, that i want to show the select box at any time, not only if the users (double)clicks the text. i did not found any option on the plugin site, so i ask you if there is another solution (for the plugin).
$('.col-type').editable( 'set-type.php', {
data: function(value, settings) {
return " {'1':'1','2':'2','3':'3', 'selected':'2'}";
},
onblur : "submit",
type : "select"
} );
Idea on inplace editing is to show the form only when you click element. If you always want to show the form use plain old html.
<select>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>
HI, I want to use select button in my application. So I am trying with a simple select example. I have a tried alot with different options. I could not succeed in setting the value of select button. Please gothrough the following code and correct me.
<script type="text/javascript"> dojo.require("dojo.parser");
dojo.require("dijit.form.Select");
dojo.addOnLoad(function(){
dijit.byId('selectv').set('CA',California);
});
</script>
<select name="selectv" dojoType="dijit.form.Select">
<option value="TN">
Tennessee
</option>
<option value="VA">
Virginia
</option>
<option value="WA">
Washington
</option>
<option value="FL">
Florida
</option>
<option value="CA">
California
</option>
</select>
I would like to set the value of select box using set method. I have seen different options with attr pre-1.5, but it didnt work. Please let me know the mistake. Thanks in advance.
Your set call is rather off. The line you wrote would attempt to set an attribute called CA (which doesn't exist) to whatever the value of a variable named California is (which probably doesn't exist either).
What you really want to do is probably:
dijit.byId('selectv').set('value', 'CA');
Which would set the value attribute of your Select widget to the string CA, which would result in the California option being selected (as its value is CA).
And yes, get and set are preferred over attr in 1.5 (attr will still work, but it's deprecated, and you'll see warnings if you have isDebug: true in djConfig.)
I theory seems to be the answer to the pre populated selectbox issue.
<cfselect name = "regions" query = "getRegions" selected="10" value="id" display="name" ></cfselect>
this is what it outouts
<option value="8">Dumfries & Galloway</option>
<option value="9">Dundee City</option>
<option value="10" selected="selected">East Ayrshire</option>
<option value="11">East Dunbartonshire</option>
but my option 10 is not selected automatically. The html looks ok any reason why?
Thanks,
R.
If you are using Firefox then that is probably the reason, because it keeps form values persistent across page reloads. You can use a different browser, or add something to the query string like ?abc=123.