Robotframework:在循环中单击web-elemnt经常无法找到元素

时间:2016-09-22 14:37:27

标签: python selenium robotframework

我为RF和Selenium2Library创建了一个关键字。它应该通过定期点击其他元素来等待一些元素,这些元素将更新元素应该出现的区域。我用它来等待邮箱中的邮件。

问题在于,通常无法在某些循环迭代中找到并点击“更新元素”,但它存在于屏幕截图中。任何想法为什么会发生?

Stroke

1 个答案:

答案 0 :(得分:0)

为此目的,不应使用Selenium2Library的关键字Wait Until Page Contains ElementWait Until Element Is Visible

*** Test cases ***
Your Test Case
  Prerequisite steps
  Wait Until Page Contains Element  ${locator}
  Succeeding steps

编辑:以下是您的Python代码在纯机器人语法中的样子。

${iteration}=  Evaluate  ${wait_interval} / ${renew_interval}
: FOR   ${i}  IN RANGE  0  ${iteration}
\   Click Element   ${renew_locator}
\   Sleep  1
\   ${is_visible}=  Run Keyword And Return Status  Element Should Be Visible  ${element_locator}
\   Exit For Loop If  ${is_visible}
\   Run Keyword If  '${is_visible}' == 'False'  Sleep  ${renew_interval}
Click Element  ${element_locator}