gpt4 book ai didi

selenium - 我可以为 Protractor 设置更长的超时时间以连接到 selenium 驱动程序吗?

转载 作者:行者123 更新时间:2023-12-02 04:48:23 26 4
gpt4 key购买 nike

远程运行我的 Protractor 测试 (jenkins) 有时会导致超时错误。那不是确定性的。

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
[launcher] Process exited with error code 1

/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1761
throw error;
^
Error: Timed out waiting for the WebDriver server at http://10.97.193.53:4455/wd/hub
at Error (<anonymous>)
at onResponse (/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:87:11)
at /opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:42:21
at /opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.js:96:5
at ClientRequest.<anonymous> (/opt/jenkins.dir/workspace/my-jenkins-job/integration-test/ui/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145:7)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1548:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:448:13)

然而,当我在我的 mac 上本地运行测试时,没有问题,测试运行完美。

我曾尝试在远程机器上手动启动 selenium 服务器,我发现有时它会立即运行,有时我必须等待一分钟。

我的问题是:有什么方法可以让 Protractor 等待 webdriver 连接更长时间吗?

环境细节

  • 机器:Red Hat 4.4.7-11
  • Protractor 版本:1.8.0
  • Selenium 服务器独立版:2.45.0

最佳答案

您可以使用 driver.wait 函数指定它。

var webdriver = require('selenium-webdriver');
var protractor = require('protractor');

var driver = new webdriver.Builder().usingServer("seleniumAddress").build();
var browser = protractor.wrapDriver(driver);

browser.driver.wait(driver.getWindowHandle(), 5000, 'Server should start within 5 seconds');

引用:

  1. http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.wait

  2. http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.getWindowHandle

关于selenium - 我可以为 Protractor 设置更长的超时时间以连接到 selenium 驱动程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30916970/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com