我的NightwatchJS测试工作正常然后他们突然停止工作,我收到了这个错误:
Running: Google Simple Search Test
Error processing the server response:
The command 'POST /wd/hub/session' was not found.
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value: -1, error: 'Unexpected token T in JSON at position 0' }
我在一个新文件夹中开始新鲜,并从https://github.com/ChrisZie/nightwatch-boilerplate下载了测试项目,它提供了完全相同的响应,让我觉得这是本地的一些问题:)
我试图谷歌错误但找不到任何答案。
const seleniumServer = require('selenium-server');
const chromedriver = require('chromedriver');
const geckodriver = require('geckodriver');
const phantomjs = require('phantomjs-prebuilt');
const dockerSeleniumHub = 'seleniumhub';
const argv = require('yargs').argv;
if (argv.cucumber) {
require('nightwatch-cucumber')({
cucumberArgs: ['--require', 'timeout.js', '--require', 'features/step_definitions', '--format', 'pretty', '--format', 'json:features/reports/cucumber.json', 'features']
});
}
module.exports = {
selenium : {
start_process : true,
server_path : seleniumServer.path,
log_path : '' ,
selenium_host : '127.0.0.1',
selenium_port : 4444,
cli_args : {
'webdriver.chrome.driver' : chromedriver.path,
'webdriver.gecko.driver' : geckodriver.path,
'webdriver.ie.driver' :'' ,
'webdriver.firefox.profile':''
}
},
test_settings : {
default : {
launch_url : 'https://www.google.com',
silent : true,
disable_colors: false,
screenshots: {
enabled: true,
on_failure: true,
on_error: false,
path: 'screenshoots/' // relativ to src directory
},
desiredCapabilities : {
browserName : 'chrome',
javascriptEnabled : true,
acceptSslCerts : true,
'phantomjs.binary.path': phantomjs.path
},
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
},
phantomjs: {
desiredCapabilities: {
browserName: 'phantomjs',
javascriptEnabled: true,
acceptSslCerts: true,
'phantomjs.binary.path': phantomjs.path
}
},
local_docker:{
selenium_host: dockerSeleniumHub,
selenium_port: 4444,
start_process : false,
desiredCapabilities: {
browserName: 'firefox'
}
},
mocha: {
test_runner: {
type: 'mocha',
options: {
ui: 'bdd',
reporter: 'list'
}
}
}
}
};
答案 0 :(得分:0)
我弄清楚出了什么问题并在此发布,因为我之前找不到答案。
我的问题是已经有一些服务使用相同的端口,所以我使用
检查lsof -i tcp:4444
然后我用
kill -quit <PID>
现在它有效!