Issue with bounding box after update


I am still a bit new to robot framework, so starting up.

So I have recently updated my test framework:
Python: 3.9 → 3.10
Robotframework: 4.1.1 → 6.1
Robotframework-browser: 8.0.2 → 16.2.0

After this update the “Get BoundingBox” keyword does not work anymore in some cases.

This error is shown:

I try to explain this as good as I can. Here is the Pease of the code, so when ${elements} only has 1 entry (in list) than it works. However when there are more entries (in my case 4) than it does not work and the error is shown. I have investigate all variables, and they contain the expected data. Also when compared to the old versions I used it all checks out, and there it works as expected. Any help will be much appreciated.

${elements}=    Get Elements    ${selector}
FOR    ${element}    IN    @{elements}
    ${box}=    Get BoundingBox    ${element}
    IF    ${box}
        Append To List    ${bounded_elements}    ${element}
1 Like

Hi Andre,

You’ve jumped quite a few versions so something might have changed behaviour slightly

There is nothing in the documentation that Get BoundingBox supports a list of elements or element selectors, however the documentation does mention

Keyword uses strict mode, see Finding elements for more details about strict mode.

Following that link tells you

If strict mode is true and locator finds multiple elements from the page, keyword will fail

And that would probably cause ${box} to be equal to None and explain the error you’re getting.

I would suggest you start with adding the line:

Log    ${element}

before the line

${box}=    Get BoundingBox    ${element}

and after that add

Log    ${box}

To check that ${element} is a single element and not a list and to see what was returned to ${box}, that way you can try to narrow down which of those changes is causing you issues.


Hi Dave,

First of all, thanks for replying to my question.

Since the “FOR ${element} IN @{elements}” iteration will make sure that “Get BoundingBox” only has to deal with 1 element at a time, I do not think that the “strict mode” is the issue. I have tested it to be sure, but with the same result.

I have done some more tests, as suggested. If I log the ${element} before “Get BoundingBox” I get 1 element, as expected. So “Get BoundingBox” only has to deal with 1 element at the time. However it fails right away at the first element, so the variable ${box} is never set

FOR ${element} IN @{elements}
Log ${element}
${box}= Get BoundingBox ${element}
Log ${box}
IF ${box}
Append To List ${bounded_elements} ${element}


So I did also test if the iteration works, by only logging the elements. This works as expected

FOR ${element} IN @{elements}
Log ${element}

All 4 expected elements are logged

So it it seems to be certain that the issue is with the “Get BoundingBox” keyword in combination with “FOR…IN” iteration.



Hi Andre,

Just looking at your reply I realised what might be the problem, is the contents of @{elements} the output of something like Get Elements?

referring to the documentation for Get BoundingBox, the first argument is:

selector <str>

It’s expecting a string not an element (object), so maybe you need to approach your for loop differently?

If I’m right then you couldtry something like this

${ecount}=    Get Count    @{elements}
FOR    ${i}    IN RANGE    ${ecount}
    ${box}=    Get BoundingBox    (//you/xpath/to/elements)[${i}]



After testing, reading, learning :slightly_smiling_face:, I found the issue.

We are using “get boundingbox” to check it the item is really shown on the webpage, because there can be more but 1 is shown. In the old versions the iteration continued when there was no bounding box and eventually found 1 with a result, but now the test stops and fails when there is no boundingbox found.

So I tried to fix it with “Run Keyword And Ignore Error”, this works but makes the test way slower… So anyone any suggerstions on that? :wink:

Hi Andre,

I suspect it’s not Run Keyword And Ignore Errorthat’s causing the slowness but rather Get Boundingbox is running until it times out.

You might be able to use Set Browser Timeout to set the timeout to a lower value say 30 sec just before you call Run Keyword And Ignore Errorand Get Boundingbox but don’t forget to set the timeout back before you continue (see example in the help for how to do that)