【发布时间】:2017-12-27 11:56:20
【问题描述】:
我即将基于vuejs创建一个应用完整的js。关注https://github.com/vuejs-templates/webpack,我开始了一个项目:
$ vue init webpack my-project && cd my-project && yarn install
当我运行 unittest yarn run unit 时一切正常,但是当我运行 yarn run e2e 运行 nightwatch.js 时,我收到此错误:
> Starting dev server...
Starting to optimize CSS...
> Listening at http://localhost:8889
Starting selenium server... started - PID: 23451
started - PID: 23451
[Test] Test Suite
=====================
Running: default e2e tests
[client :: capabilities] Test Suite
=======================================
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: socket hang up
at createHangUpError (_http_client.js:344:15)
at Socket.socketOnEnd (_http_client.js:436:23)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9) code: 'ECONNRESET' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
selenium 服务器在e2e 测试开始时即时启动,并在它们完成时关闭。我敢肯定,因为当我在失败之前停止nightwatch.js 时,我看到了:
$ ps aux | grep -i selenium
java -Dwebdriver.chrome.driver=node_modules/chromedriver/lib/chromedriver/chromedriver -jar node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar -port 4444
所以基于我得到的输出的真正错误很可能是Error retrieving a new session from the selenium server。我该如何解决这个问题?
package.json
"chromedriver": "^2.27.2",
"cross-spawn": "^5.0.1",
"nightwatch": "^0.9.12",
"selenium-server": "^2.53.1",
test/e2e/nightwatch.conf.js
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
【问题讨论】:
标签: vuejs nightwatch.js selenium e2e nightwatch.js selenium automation nightwatch.js e2e-testing