Reputation: 971
I have the following line in Robot Framework
Wait for condition 'Get element attribute id:something attribute=something_else' == 'abc'
I think this is pretty self explanatory: I want to wait until Get element attribute
returns abc
.
However, this returns an error message
Wait for condition expected 1 to 3 arguments, got 5.
On an abstract level, this error message is pretty clear but I don't understand how it applies here. The five arguments it refers to are arguments not to Wait for condition
but to Get element attribute.
I want to send two arguments to Wait for condition
that should be equal, the return value from Get element attribute
and the string abc
.
How do I write this?
Upvotes: 1
Views: 6040
Reputation: 20067
In the other answer it was rightfully pointed out the Wait For Condition
keyword is just for js code being ran in the browser. Here's how to do what you want with the builtin keyword Wait Until Keyword Succeeds
and SeleniumLibrary's Element Attribute Value Should Be
:
Wait Until Keyword Succeeds retry=1 minute retry_interval=5 seconds Element Attribute Value Should Be id:something attribute=something_else expected=abc
The Element Attribute Value Should Be
is new in Selenium Library v3.2, if you don't have this version yet, here's a sample implementation:
Attribute Value Should Be
[Documentation] Fails if the element's attribute is not the expected one
[Arguments] ${locator} ${attribute} ${expected}
${value}= Get Element Attribute ${locator} ${attribute}
Run Keyword If """${value}""" != """${expected}"""
... Fail The attribute's value is different from the expected: ${value} != ${expected}
Upvotes: 2
Reputation: 385970
This is not how wait for condition
works. You can't give it a keyword. You must give it a javascript expression.
From the documentation:
The condition can be arbitrary JavaScript expression but it must return a value to be evaluated. See Execute JavaScript for information about accessing content on pages.
Upvotes: 3