Paulliev Posted March 11, 2021 Share Posted March 11, 2021 (edited) Hello, I use _WD_ElementOptionSelect to select an option in my dropdown, one problem. The input can be lower case or upper case, depends what the user fills in. Can I make this someway non case-sensitive? See my code below: $Product = "adminview" ; Select option is AdminView and won't select it now. _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='custom_field_49325']//option[contains(text(),'" & $Product & "')]") I found the function StringCompare, but then I need to compare to the select options, is there a faster way to do it? Edited March 11, 2021 by Paulliev Link to comment Share on other sites More sharing options...
Danp2 Posted March 11, 2021 Share Posted March 11, 2021 Something like this should work -- _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='custom_field_49325']//option[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '" & $Product & "')]") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Paulliev Posted March 11, 2021 Author Share Posted March 11, 2021 @Danp2 Thanks for your answer. As I said: "The input can be lower case or upper case, depends what the user fills in" The translate you gave me purely sets everything to lowercase right? But my select options are not all lowercase. So it really needs to be non case sensitive just the text needs to be the same. Link to comment Share on other sites More sharing options...
Danp2 Posted March 11, 2021 Share Posted March 11, 2021 What I posted changes the text of the select element's options to lowercase. If $Product is the user input, just convert it to lowercase as well so that the comparison will work as intended. Paulliev 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Paulliev Posted March 12, 2021 Author Share Posted March 12, 2021 Goodmorning @Danp2! Sorry for my wrong interpretation, thanks for you clear answer. It works as always! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now