【问题标题】:Cannot run webdriver.io tests while offline离线时无法运行 webdriver.io 测试
【发布时间】:2018-04-02 00:11:41
【问题描述】:

我正在我的本地主机上开发一个 React 站点,并开始使用 webdriver.io 添加 e2e 测试。所有 webdriver.io 测试在未连接到互联网时都会失败,但一旦连接就会通过。我怎样才能解决这个问题?测试通过 gulp 运行。

错误:

alan:/var/www/mysite.local$ gulp webdriver
[17:01:11] Using gulpfile /private/var/www/mysite.local/gulpfile.js
[17:01:11] Starting 'webdriver'...

A service failed in the 'onPrepare' hook
Error: Could not request headers from https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-macos.tar.gz: Error: getaddrinfo ENOTFOUND github.com github.com:443
    at Request.<anonymous> (/private/var/www/mysite.local/node_modules/selenium-standalone/lib/install.js:552:8)
    at Request.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/private/var/www/mysite.local/node_modules/selenium-standalone/node_modules/request/request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)

Continue...
ERROR: connect ECONNREFUSED 127.0.0.1:4444
chrome
    at new RuntimeError (/private/var/www/mysite.local/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
    at Request._callback (/private/var/www/mysite.local/node_modules/webdriverio/build/lib/utils/RequestHandler.js:330:43)
    at self.callback (/private/var/www/mysite.local/node_modules/webdriverio/node_modules/request/request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/private/var/www/mysite.local/node_modules/webdriverio/node_modules/request/request.js:878:8)
    at emitOne (events.js:101:20)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)

[17:01:13] 'webdriver' errored after 1.06 s
[17:01:13] Error in plugin 'gulp-webdriver'

wdio.conf.js 文件:

exports.config = {
  specs: ["./webdriver/*.test.js"],
  exclude: [
  ],
  maxInstances: 10,
  capabilities: [
    {
      maxInstances: 5,
      browserName: "chrome"
    }
  ],
  sync: true,
  logLevel: "silent",
  coloredLogs: true,
  deprecationWarnings: true,
  bail: 0,
  screenshotPath: "./webdriver/errorShots/",
  baseUrl: "http://mysite.local",
  waitforTimeout: 10000,
  connectionRetryTimeout: 90000,
  connectionRetryCount: 3,
  services: ["selenium-standalone"],
  framework: "mocha",
  reporters: ["dot"],
  mochaOpts: {
    ui: "bdd",
    compilers: ["js:babel-register"]
  }
};

Gulp 任务:

gulp.task("webdriver", function() {
  return gulp
    .src("wdio.conf.js")
    .pipe(webdriver())
    .once("end", () => {
      process.exit();
    });
});

谢谢。

【问题讨论】:

  • 在你的 gulp 脚本中你已经指定它需要连接到互联网来下载东西,发布/private/var/www/mysite.local/gulpfile.js的内容
  • gulpfile 中没有任何内容请求下载。我已将 gulpfile 任务添加到原始帖子中。

标签: reactjs e2e-testing webdriver-io


【解决方案1】:

selenium-standalone 有一个下载脚本,用于安装浏览器驱动程序。我相信您可以在连接到 Internet 时运行测试脚本,然后一旦下载了所有驱动程序,您就可以在没有连接的情况下运行。

【讨论】:

  • 感谢 klamping 的响应,但在连接到 Internet 的情况下运行测试后它不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-10
  • 1970-01-01
  • 2019-03-13
相关资源
最近更新 更多