离线

时间:2018-04-02 00:11:42

标签: reactjs e2e-testing webdriver-io

我正在我的localhost上开发一个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();
    });
});

谢谢。

1 个答案:

答案 0 :(得分:0)

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