有时使用Robot Framework无法看到元素

时间:2015-10-24 10:32:02

标签: robotframework

我第一次使用Robot FW并面临一个问题 - 其中一个测试用例需要打开一个模态确认对话框,然后按下一个按钮"删除"被压了。测试用例的关键字如下:

Delete Test Data
    [Arguments]    ${name}  
    Wait Until Element Is Visible    xpath=//tr[@item_name='${name}']  
    Click Button    xpath=//tr[@item_name='${name}']//button[@class='btn btn-sm btn-danger']
    Wait Until Element Is Visible    id=deleteItem    timeout=10
    Click Button    Delete    
    Wait Until Element Is Not Visible    xpath=//tr[@item_name='${name}']

Wait Until Element Is Visible id=deleteItem timeout=10导致所有问题。有时元素在时间限制内可见,有时则不可见。我将超时时间增加到10秒,但它无法解决问题。如何在不失败的情况下每次都显示对话框?感谢任何帮助,谢谢!

3 个答案:

答案 0 :(得分:0)

我也面临同样的失败。

我能够通过使用" Wait Until Keyword成功解决这个问题"关键字。

"等到关键字成功"关键字,重复检查等待条件,直到条件通过或超时期限到期。

e.g。

等到关键字成功1分1秒元素应该可见xpath = //输入[@id =' aName']

答案 1 :(得分:0)

我的方法是将“等待元素可见”更改为Wait Until Page Contains Element,如下所示。

${check_element}=  Run Keyword and Return Status   Wait Until Page Contains Element    locator    10s
Run Keyword If      '${check_element}' == 'True'     Click Element  locator

更改此关键字的原因是,有时元素已被加载并在DOM或页面中可用,但是可见性被隐藏了。这种间歇性的怪异事情有时会发生在我身上。

答案 2 :(得分:-1)

尝试使用Wait Until Element Is Clickable因为它是一个按钮,它应该可以解决您的问题。

所以,它应该像

Wait Until Element Is Clickable deleteItem timeout=10

相关问题