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.
Comparing the text in the drop down
Hi ,
Is there any option in SAHI to compare a text in a drop down with any string using 'like'/'contains' or something like that.
I need this function to validate if the drop down values are populated correctly.
eg. It is expected that the drop down is populated with
-Select-
Long term care
Critical Illness
....
.....
instead of
-Select-
::INSURANCE_1::EN
::INSURANCE_2::EN
.....
If the drop down has '::INSURANCE_%' ,it is an issue and need to be fixed.
I know I can compare them with the list of correct values, but in few places the drop down values are dynamic and it very tedious to list the values for the entire application.
Thanks,
Is there any option in SAHI to compare a text in a drop down with any string using 'like'/'contains' or something like that.
I need this function to validate if the drop down values are populated correctly.
eg. It is expected that the drop down is populated with
-Select-
Long term care
Critical Illness
....
.....
instead of
-Select-
::INSURANCE_1::EN
::INSURANCE_2::EN
.....
If the drop down has '::INSURANCE_%' ,it is an issue and need to be fixed.
I know I can compare them with the list of correct values, but in few places the drop down values are dynamic and it very tedious to list the values for the entire application.
Thanks,
This discussion has been closed.
Comments
try something like _assertEqual("yourText", _select("identifier").options[$index].text) and loop through _select("identifier").options.length
Regards
Wormi
Thanks for your reply.
I understand your solution , but in my case , the " your text" is not a entire text I am comparing.
If you read my post again, you will understand.
I am comparing 'abcde' with '%bc%'.
Thanks again.
try _assertContainsText or _assertTrue(_select("identifier").options[$index].text.match("Your Text"))
the "match" solution should work with regular expressions, that may be usefull too,
I guess _assertContainsText would work for me.Let me try.
Once again thanks for your prompt reply.
I hope it works. Just ask when you encounter further problems.
Here is the code from script and the corresponding error:
The selected value in the drop down is " **INSURANCE_PRODUCT_TYPE_8:EN**"
Am I missing anything with the syntax??
Error I got on SAHI console is :
TypeError: 'undefined' is null or not an object
No trace available
Any thoughts on this ?
Thanks.
Hope this helps someone who is looking for a solution.
Thanks.