Issue interacting with element list returned by get elements keyword

Hello all,

I recently have problems with my test suite using Browser lib,
I frequently use get elements keyword to retrieve a list of elements. Then I perform a FOR loop on it to click on each element of the list
something like :

${element list} = get elements  <my selector>
FOR  ${Element}  IN  @{element list} 
   click  ${element}

I have recently upgraded my robot + browser versions to latest one (and this is leading to some errors. It happens that one of the click failed as it can not find the element : (waiting for selector “button.filter-active .mericon-close >> nth=2” …)

I think it is related to issue : Get Elements optionally to return unique css selectors · Issue #1307 · MarketSquare/robotframework-browser · GitHub
and have also posted a message there but anyone experienced this recently ?

robotframework 4.1.2
robotframework-browser 11.0.0

Thanks for you feedbacks !

to complement my question the workaround that I have identified is to do something like :

  ${element count} = get element count  <my css selector>
  FOR   ${index}  IN RANGE  ${element count}
       ${element list} =  Get elements  <my css selector>
       click   ${element list} [0]

this will make refresh the DOM element list every iteration of the loop
not very nice but did not find any other idea

Interesting that you did have to modify the usage of the library. There is difference starting from release 10 that moved to use Playwright Locators instead of pointing to ElementHandles. Locators are resolved only when they are used, but that example should work in similar manner.

Do you need me to provide more details about this use case?

Yes, if yo can create an example, which also I can run, that would help a lot.

I finally got it …
In my UI under test, there are list of object with a delete button in each
My test get all these delete button from all the elements using the get elements with the correct locator
It then loop on the list of element and click on it
So the DOM element disappear from the page after the click and I think that the element list retrieved at the beginning is no more accurate.
It used to work before release 10 as ElementHandles did not changed but if now resolution is dynamic this does not work anymore

Hi @Sebplais ,

in situations where you are deleting/removing things from a list, I find it’s best to work from the bottom up, i.e. get the count, action the last and decrement the count, that way the item numbers don’t change and the number item you want to action still exists (only the ones after that have been removed.

Hope that helps,


Indeed thanks for the suggestion !