Handling Dropdown - Select Option By Label Contains Symbol

Hi all, I need your help to solve my problem
The case is, i have a dropdown object with option ‘user’, ‘user (internal)’, etc. I want to select ‘user (internal)’, but got an error “no option matched”

I realized that the error caused by the bracket symbol ‘(’ and ‘)’ from ‘user (internal)’, so somehow it didn’t matched. any solution to solved this problem?

I really appreciate your suggestion, thank you :slight_smile:

@Willis_Williandy selectOptionByLabel should not have a problem with parenthesis’ as long as you use the appropriate quotes on the end and you do not have the boolean set to “true”. My suggestion is to go to the web page’s code and copy the options from there and paste them in KS, that way you have an exact match.

You can also, if you are concerned, is put double back slashes in front of any character that could be construed as part of regular expression and then set the boolean to “true”. The Option would look different but will still match. An example,
image

@grylion54 hi, thanks for the reply. I’ve tried to copy the option from the web page code (and make sure the boolean set to true), but the error still same ‘no option matched’. from here also I figured out that I only can’t select the option label if the label using bracket symbol (cause I already tried to select option ‘user’, and it worked properly).
for your suggestion, using regular expression, also didn’t worked for me. Any other option maybe? :frowning:

@Willis_Williandy
Note that you should have the boolean set to false unless there is some regular expression that you are doing, like \d{1,2}. If you do not have any regular expression stuff, then set the boolean to false, such as (without reg exp):

WebUI.selectOptionByLabel(findTestObject(‘myPage/myTO’), “user (internal)”, false)

or (with reg exp)

WebUI.selectOptionByLabel(findTestObject(‘myPage/myTO’), “user .*”, true)

–the dot asterisk means everything else, so it is “user” with a space and anything else following). The problem with this is if there is anything similar, such as “user (external)” because KS won’t choose between “user (internal)” or “user (external)” since to reg exp they are the same (KS will choose neither).

And to confirm, when you look at the web page’s code, are you seeing the user and user (internal) as labels? Or are they part of the value attribute, such as value=“user” or value=“user (internal)”? I’m trying to find out if we are using the correct method. Again, I have selects with a lot more than parenthesis in my TCs and they work.

If the select has values as well as labels, then change the method and use the value attributes with selectOptionByValue.

Ahhh I got it. Thanks for your help. My bad to miss understanding the boolean that you mentioned before ><