Robot Framework:如何等待来自selenium库的关键字返回true或false

emi*_*emi 2 selenium wait robotframework

如果页面上有元素,我想运行关键字.

我尝试使用Selenium库的Wait Until Page Contains Element关键字,但无论元素是否存在,它都将始终返回"None".我尝试设置自定义错误,但这也不起作用:

${condition} =     Wait Until Page Contains Element    ${locator}    timeout=5   error=false
Run Keyword if  '${condition}'=='false'       click element  ${some_refreshButton_locator}
Run Code Online (Sandbox Code Playgroud)

关键字点击元素$ {locator}将仅在我创建条件'$ {condition}'=='无'时运行

我做错了什么,我怎么能让Selenium Library等到...关键字返回true或false.

谢谢!

小智 5

等到页面包含元素不返回任何内容,但如果找不到元素则会引发错误.一种解决方法是围绕它包装Run Keyword和Ignore Error.

*** Settings ***
Library    Selenium2Library

*** Test Cases ***
Test wait
    Open Browser        http://www.google.com/    gc
    ${result}    ${condition}=    Run Keyword And Ignore Error    Wait Until Page Contains    Stackoverflow    timeout=2   error=false
    Run Keyword if  '${condition}'=='false'       Log    clicking
    Close All Browsers
Run Code Online (Sandbox Code Playgroud)