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.
How to select value from the combo box / option list?
Hello Team,
I have two combo box / drop down list in my application and I have written following code to select the values in combo box / drop down list.
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$ddlPartyType"), "Non Legal Party");
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$ddlRelationshipType"), "Sample Relationship Type");
Here I have mentioned hard coded values in _setSelected() method. Those are "Non Legal Party" and "Sample Relationship Type".
How can I select any value from the list based on the ID of the option rather than passing the hard coded value?
Suppose my list name is List1 whih contains folloing option:
1. Blue
2. Yellow
3. Red
Now if i want to select the option "Yellow" then I have to write following code:
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1"), "Yellow");
But how can I select the same option using the List ID means is it possible to seelct the option in the list based on its displayed order like:
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1"), 2); ----> Here I am pasing '2' as the ID of the "Yellow" option is '2' in the list?
Is it posible?
Is it Possible to select the option from th option list dynamically rather than passing the hard coded value?
Thanks,
Ashvin Patel
I have two combo box / drop down list in my application and I have written following code to select the values in combo box / drop down list.
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$ddlPartyType"), "Non Legal Party");
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$ddlRelationshipType"), "Sample Relationship Type");
Here I have mentioned hard coded values in _setSelected() method. Those are "Non Legal Party" and "Sample Relationship Type".
How can I select any value from the list based on the ID of the option rather than passing the hard coded value?
Suppose my list name is List1 whih contains folloing option:
1. Blue
2. Yellow
3. Red
Now if i want to select the option "Yellow" then I have to write following code:
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1"), "Yellow");
But how can I select the same option using the List ID means is it possible to seelct the option in the list based on its displayed order like:
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1"), 2); ----> Here I am pasing '2' as the ID of the "Yellow" option is '2' in the list?
Is it posible?
Is it Possible to select the option from th option list dynamically rather than passing the hard coded value?
Thanks,
Ashvin Patel
Comments
See if this works:
_setSelected(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1"), _getText(_select("ctl00\$ContentPlaceHolder1\$uMatterParty\$List1").options[1]));
will select option with index 1.
Regards,
Pankaj.
The current implementation of _setSelected is too basic. I have modified the code for _setSelected to handle identification of options using their ids, or their index. Open sahi/htdocs/spr/concat.js, search for "_setSelected", and replace that function with this code: If you are not sure, let me know, I can email you a build.
Regards,
Narayan
The solution you have provided is perfectly working.
Thanks for the code change.
Regards,
Ashvin