在 Robot Framework 中等待条件的参数太多?
Too many arguments to Wait for condition in Robot Framework?
我在 Robot Framework 中有以下行
Wait for condition 'Get element attribute id:something attribute=something_else' == 'abc'
我认为这很容易解释:我想等到 Get element attribute
returns abc
.
但是,这 return 是一条错误消息
Wait for condition expected 1 to 3 arguments, got 5.
在抽象层面上,此错误消息非常清楚,但我不明白它如何适用于此。它引用的五个参数不是 Wait for condition
而是 Get element attribute.
的参数我想向 Wait for condition
发送两个应该相等的参数,来自 [=12 的 return 值=] 和字符串 abc
.
这个怎么写?
这不是 wait for condition
的工作方式。你不能给它一个关键字。你必须给它一个 javascript 表达式。
来自文档:
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.
在另一个答案中正确地指出 Wait For Condition
关键字仅适用于在浏览器中为 运行 的 js 代码。以下是如何使用 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
Element Attribute Value Should Be
是 Selenium Library v3.2 中的新版本,如果您还没有这个版本,这里有一个示例实现:
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}
我在 Robot Framework 中有以下行
Wait for condition 'Get element attribute id:something attribute=something_else' == 'abc'
我认为这很容易解释:我想等到 Get element attribute
returns abc
.
但是,这 return 是一条错误消息
Wait for condition expected 1 to 3 arguments, got 5.
在抽象层面上,此错误消息非常清楚,但我不明白它如何适用于此。它引用的五个参数不是 Wait for condition
而是 Get element attribute.
的参数我想向 Wait for condition
发送两个应该相等的参数,来自 [=12 的 return 值=] 和字符串 abc
.
这个怎么写?
这不是 wait for condition
的工作方式。你不能给它一个关键字。你必须给它一个 javascript 表达式。
来自文档:
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.
在另一个答案中正确地指出 Wait For Condition
关键字仅适用于在浏览器中为 运行 的 js 代码。以下是如何使用 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
Element Attribute Value Should Be
是 Selenium Library v3.2 中的新版本,如果您还没有这个版本,这里有一个示例实现:
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}