Select Options By in Browser Library fails even though it finds the value

When I use the following I get a timeout error:

Select Options By xpath=//select[@id="action"] value edit

However if I allow it to ignore the error it actually selects the correct option

This works:

Run Keyword And Ignore Error Select Options By xpath=//select[@id="action"] value edit

I use this menu a lot and my time out is set to 120 seconds so this makes my tests take forever. Is there a better way to select an option for a list?

    <select class="btn btn-primary btn-xs" id="action">
        <option value="0"  disabled selected hidden>Action</option>
        <option class="action_menu" value="edit">Edit</option>
	    <option class="action_menu" value="copy">Copy</option>
	    <option class="action_menu" value="delete">Delete</option>
	    <option class="action_menu" value="lock">Lock</option>	    
	    <option class="action_menu" value="unlock">Unlock</option>
	    <option class="action_menu" value="submit">Publish</option>
	    <option class="deletefolder" value="deletefolder">Delete folder</option>
	</select>

Hi

Are you able to confirm if this is the first action you’re doing on page load? If so, it could just be the case of waiting for said option to be visible/said state before interacting with it.

Browser library is very quick so this sounds like you just need to slow it down a little, without more context on the steps prior to the select.

You’d be able to use the below before if this is why:https://marketsquare.github.io/robotframework-browser/Browser.html#Wait%20For%20Elements%20State

Thanks

I’ve tried using the ‘Wait For Element State’ but still get same result. I can’t use it after the ‘Select Options By’ because it errors out before then. It actually does successfully click on the element and go to the page in the test but it doesn’t think it successfully selects it so the test fails.

I’ve tried Index, Value, and Text options but same issue.

I have no clue what could be the reason but i have a question; Does clicking on the option trigger instant navigation ?

I am not quite sure what you mean by instant navigation. Clicking on the ‘edit’ option does bring you to a different page that no longer has that dropdown list on it.

But other options do not navigate away from the page (like the unlock) and I still have the same issue.

Clicking on the ‘edit’ option does bring you to a different page that no longer has that dropdown list on it.

Essentially an url change after clicking on option was what i meant. So, yes.

For the actually issue I’d try just Click directly to the option if that would work and not using that dedicated keyword from the browser library.

Something like

Click     //option[value="edit"]

I get an error saying the selector is hidden when I try this:

Hi Jeff,
If your option menu is something like this (mock up from w3schools):
image

Then you might have to click the option menu first to open it, then click the edit option, something like this:

Click     //select[id="your select"]
Click     //option[value="edit"]

Dave.

1 Like