18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
drop down list selection
Hi all
I have requirement to test the details of the members which are populated in the drop down list by selecting one by one since the number of drop down list is not fixed based on the logged in user i have counted the length but i don't know its not working... i am new to automation ..please help me on this
var $nItemsInDropdown
_set($nItemsInDropdown,_select(ddlUser).options.length);
for(var $y=0;$y<$nItemsInDropdown;$y++)
{
_click(_getSelectedText(_select("ddlUser").options[$y].value));
}
i am getting the below error
_sahi.setServerVar('\$nItemsInDropdown', _select(ddlUser).options.length);
TypeError: 'ddlUser' is undefined
No trace available
ddluser is the name of the drop down list.....
I have requirement to test the details of the members which are populated in the drop down list by selecting one by one since the number of drop down list is not fixed based on the logged in user i have counted the length but i don't know its not working... i am new to automation ..please help me on this
var $nItemsInDropdown
_set($nItemsInDropdown,_select(ddlUser).options.length);
for(var $y=0;$y<$nItemsInDropdown;$y++)
{
_click(_getSelectedText(_select("ddlUser").options[$y].value));
}
i am getting the below error
_sahi.setServerVar('\$nItemsInDropdown', _select(ddlUser).options.length);
TypeError: 'ddlUser' is undefined
No trace available
ddluser is the name of the drop down list.....
This discussion has been closed.
Comments
_select("ddlUser") ?
Thanks for ur prompt reply..
i have removed the quotes as u sad but still is not working the below is the modified code
_click(_div("divFamilylock")); is used to open the drop down
for(var $y=0;$y<(_select(ddlUser).options.length);$y++)
{
_click(_div("divFamilylock"));
_click(_getSelectedText(_select(ddlUser).options[$y].value));
}
I see the below error in logs
ERROR
ReferenceError: "ddlUser" is not defined. at Mar 4, 2011 4:01:41 PM
please correct me if i am wrong
_click(_getSelectedText(_select("ddlUser").options[0].value));
TypeError: 'options.length' is null or not an object
No trace available
In my application the Drop Down list items generated are dynamic and is loaded based on the logged in user
It sets the value correct but it lacks the clicking... if the clicking is needed, I can't find a workaround right now
Please excuse me if am wrong since i am very new to automation
_click(_link("Claims Status"));
var $nItemsInDropdown
_set($nItemsInDropdown,_select(ddlUser).options.length);
for(var $y=0;$y<$nItemsInDropdown;$y++)
{
_click(_div("divFamilylock"));
_click(_setSelected(_select("ddlUser"), _select("ddlUser").options[$y].text));
}
yes i need clicking of each item in dropdown one by one..
Thanks in advance
_click(_link("Claims Status"));
var $nItemsInDropdown =_select(ddlUser);
for(var $y=0;$y<$nItemsInDropdown.options.length;$y++)
{
_click(_div("divFamilylock"));
_setSelected($nItemsInDropdown, $nItemsInDropdown.options[$y].text));
}
if not, please post the errors
i am getting the below error when i execute the above code
ERROR
ReferenceError: "ddlUser" is not defined. at Mar 8, 2011 4:08:33 PM
Thanks in Advance
change this line
var $nItemsInDropdown =_select(ddlUser);
to
var $nItemsInDropdown =_select("ddlUser");
The code which u gave is working fine without any errors but the problem is it is not selecting the values in drop down instead it skips and goes to next line.....
_setSelected($nItemsInDropdown, $nItemsInDropdown.options[$y].text));
if yes, you could try to just add a
_click($nItemsInDropdown) ;
after this line so that it looks like
_click(_link("Claims Status"));
var $nItemsInDropdown =_select("ddlUser");
for(var $y=0;$y<$nItemsInDropdown.options.length;$y++)
{
_click(_div("divFamilylock"));
_setSelected($nItemsInDropdown, $nItemsInDropdown.options[$y].text));
_click($nItemsInDropdown) ;
}
You can select an option in a select box using index also.
So you could have done:
Any how sahi rocks.....