Hello,
I am really struggling trying to select items from a dropdown. Here is the code snippet:
I don’t think I can use Select Option By here. I have also tried using WebUI.click using the full xpath, which ends up only selecting the first item in the list no matter what option I want to select.
Any help would be greatly appreciated.
Correct.
I can’t help you with xpath - I only use CSS (you know, like the rest of the web does).
This css is a selector that targets the element you highlighted above:
#mat-option-0 > span
I assume you have more, mat-option-1, mat-option-2, etc. In that case this JavaScript will let you target them with a click (replace the index 0
with 1
, 2
, etc)
String js = "document.querySelector('#mat-option-0 > span').click();"
WebUI.executeJavaScript(js, null)
This worked great! Thank you!
1 Like