【问题标题】:Read value from progress bar RobotFramework从进度条 RobotFramework 读取值
【发布时间】:2021-02-22 14:22:27
【问题描述】:

我正在尝试做这个练习http://www.uitestingplayground.com/progressbar,我想在进度条达到 75% 时按下按钮。

这是我的代码

 Open Browser    http://www.uitestingplayground.com/progressbar  chrome
 Maximize Browser Window
 Click Button    css=#startButton
 Wait Until Element Contains    css=#progressBar.width 75
 Click Button    css=#stopButton
 Close Browser

谁能帮我捕获进度条状态的正确方法是什么?

【问题讨论】:

  • 让我们知道您得到的上述代码的结果是什么。
  • 首先,请考虑以下内容:Wait Until* 关键字不是“即时检查”。每隔一段时间进行轮询。现在,考虑一个轮询在宽度为 74 时命中,然后有小的延迟,然后当下一次轮询发生时,宽度已经可以达到 76 .. 然后,您的 Wait Until* 基本上会遇到超时,因为它从未见过 75在这个代码的宽度..

标签: robotframework


【解决方案1】:

您可以尝试以下完整代码并粘贴到您的 IDE 中并运行。此代码将在范围内循环,但如果它与您正在寻找的进度条匹配,它将退出。

*** Settings ***
Library  Selenium2Library
Documentation    Test file to validate the progress bar status check

*** Test Cases ***
Progress bar status
   [Tags]    Progress bar status check 
   Open Browser    http://www.uitestingplayground.com/progressbar  chrome
   Maximize Browser Window
   Click Button    css=#startButton
   :FOR    ${i}    IN RANGE    100000
      ${progress}  get element attribute  xpath=//div[@class='progress-bar bg-info']  style
      run keyword if  '${progress}' == 'width: 75%;'  run keyword  click button  css=#stopButton
      Exit For Loop IF  '${progress}' == 'width: 75%;'
 END

【讨论】:

  • 如果你能执行这个sn-p,请告诉我,我会进一步帮助你
  • 你是最棒的!它完美地工作!谢谢!
猜你喜欢
  • 1970-01-01
  • 2022-10-24
  • 1970-01-01
  • 1970-01-01
  • 2021-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多