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}
END
END
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.
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
Code:
FOR ${element} IN @{elements}
Log ${element}
${box}= Get BoundingBox ${element}
Log ${box}
IF ${box}
Append To List ${bounded_elements} ${element}
END
END
After testing, reading, learning , 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?
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)
I continued with fresh inspiration. Now I see there is a difference in the result if “get elements” in version 8.0.2 it replied with something like this: ${elements} = [‘element=2ec24859-6c7c-4b9b-9e6f-21b7e2d1ac70’, ‘element=7bb4b2a7-5e2e-442b-a674-cf4602526c9a’
In version 18.5.1 it replies like this: ${elements} = [‘.MenuPaneV >> nth=0’, ‘.MenuPaneV >> nth=1’ this causes probably the issue with Get BoundingBox.
So, is there a way to get the return of “ID’ s”? as it was in the old version. Or is there any other method? I would also be happy if there is any documentation about this “change” I was not able to find it yet.
That change in the behaviour of get elements happened quite a while ago about version 16 I think. I suspect It wasn’t initiated by browser library but by playwright that browser library uses, but I don’t know for sure.
Thanks for quick reply, the case you mentioned is indeed the same issue as I encountered. So this “issue” can be closed here, I will flag you last answer as the “solution”.