I have this drop-down menu that’s part of a modal popup for User creation:

Here is what the source code looks like:

I am trying to select one of the roles from the drop-down menu using the “selectOptionByIndex” keyword, however, it doesn’t work. It just hangs there, unable to select the item.
Here is what I have:
WebUI.selectOptionByIndex( findTestObject( LMS/roleItemsList’), 3)
Can somebody tell me how I can fix this?
Cheers,
image.png
stuff.png
selectOptionByIndex selects elements within elements. You’ll need to use click to “select” the element you need.
Have you tried either WebUI.selectOptionByLabel or WebUI.selectOptionByValue?
Jum-Ho
You’re not making it clear what is not working. Going by your HTML, I can only see the elements that appear in the dropdown once it has been opened and “dropped down”. Is the problem…
1 - Clicking on the “Choose a role” header?
Or,
2 - Clicking on “Administator”?
I can’t see from the HTML how to advise for #1… your image doesn’t show the “Choose a role” section of the HTML.
For #2, I would make the click target the element. Perhaps the element would work, too, I don’t know. But since the element contains the text of the option, it should receive the click with no issues.
Either way, you definitely do NOT want to use any of the selectOptionXXX APIs, they only work with Select/Option elements (and you don’t have any in that HTML).
Russ
1 Like
Update:
I had a silly typo in my code that was referring to a different element on the page. I’m very sorry about the miscommunication. Fixing it and applying Russ’ suggestion has solved my problem.
Thank you!
Cheers,
You’re welcome. Glad you got it working 
2 Likes