【问题标题】:When running Selenium tests on the command line, how do I execute a command only if that element is visible?在命令行上运行 Selenium 测试时,如何仅在该元素可见时才执行命令?
【发布时间】:2019-11-30 14:55:00
【问题描述】:

我正在使用 selenium-side-runner v 3.11.0 尝试从命令行对 Chrome 浏览器运行测试。如何等待执行命令直到元素可见(注意:不是“存在”而是可见)。我正在阅读这篇文章——https://ui.vision/docs/selenium-ide/waitforvisible——并认为“waitForVisible”可以工作,但是当我将它插入到我的“.side”测试中时......

 {
"id": "fbf35ed7-1a28-4540-a93d-3cb8ba0e012a",
"comment": "",
"command": "waitForVisible",
"target": "id=user_login",
"targets": [],
"value": ""
}

它因以下错误而死......

localhost:selenium davea$ PATH=/Users/davea/Documents/workspace/starter_project/selenium/dev/:$PATH selenium-side-runner --headless -c "browserName=chrome" /tmp/81a312ad-8fe1-4fb0-b93a-0dc186c3c585.side
info:    Running /tmp/81a312ad-8fe1-4fb0-b93a-0dc186c3c585.side
 FAIL  ./DefaultSuite.test.js (5.462s)
  Default Suite
    ✕ myTest (3726ms)

  ● Default Suite › myTest

    Unknown command waitForVisible

      12 |     return element.click();
      13 |   });
    > 14 |   throw new Error("Unknown command waitForVisible");
         |         ^
      15 |   await driver.wait(until.elementLocated(By.id(`user_login`)), configuration.timeout);
      16 |   await driver.findElement(By.id(`user_login`)).then(element => {
      17 |     return element.clear().then(() => {

      at Object.<anonymous>.tests.myTest (commons.js:14:9)
      at Object.<anonymous> (DefaultSuite.test.js:11:5)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        5.595s, estimated 6s

【问题讨论】:

  • 这是 Selenium IDE 还是 Selenium Webdriver?你已经标记了两个,所以你应该删除一个。
  • 我使用 Selenium IDE 记录了测试(创建了“.side”文件),并使用各种 Web 驱动程序(Chrome 的 chromedriver、Firefox 的 geckodriver 等)在命令行上运行它

标签: selenium-webdriver selenium-ide


【解决方案1】:

selenium-side-runner(命令行运行器)在这方面似乎被打破了。 https://github.com/SeleniumHQ/selenium-ide/issues/643

【讨论】:

    猜你喜欢
    • 2021-07-03
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多