node.js - 无法使用 phantomjs 和 nightwatch.js 从 org.openqa.selenium.remote.NewSessionPayload 创建会话
问题描述
我正在尝试在 nightwatchjs 中对 Phantom JS 执行测试我正在使用带有 nightwatchjs 和黄瓜的 Selenium 服务器我将以下链接作为参考 - https://github.com/nightwatchjs/nightwatch/wiki/Running-tests-in-幻影JS
还有其他答案,但没有一个与我的答案相匹配。这可能是配置问题,但我无法解决。有人可以帮我吗?
错误:
NFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"phantomjs","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","phantomjs.binary.path":"/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs","phantomjs.cli.args":["--ignore-ssl-errors=true"],"silent":false}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":270}
ERROR Response 500 POST /wd/hub/session (482ms) { value:
{ message: 'Unable to create session from org.openqa.selenium.remote.NewSessionPayload@5c510db\nBuild info: version: \'3.12.0\', revision: \'7c6e0b3\', time: \'2018-05-08T15:15:08.936Z\'\nSystem info: host: \'Chirags-MacBook-Pro.local\', ip: \'fe80:0:0:0:142a:4efe:d208:27ae%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.5\', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown',
error: 'session not created' },
status: 33 }
{ Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at ClientManager.emit (events.js:171:17)
at Nightwatch.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/runner/clientmanager.js:68:10)
at Object.onceWrapper (events.js:273:13)
at Nightwatch.emit (events.js:182:13)
at HttpRequest.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/index.js:501:10)
at HttpRequest.emit (events.js:182:13)
at IncomingMessage.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/http/request.js:172:16)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1086:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
context:
{ message: 'Connection refused! Is selenium server started?\n',
data: { value: [Object], status: 33 } } }
它说driver.version:unknown,这可能是问题吗?
所有组件都是最新版本
"cucumber": "^4.0.0",
"nightwatch": "^0.9.21",
"nightwatch-cucumber": "^9.1.2",
"phantomjs-prebuilt": "^2.1.16",
"selenium-server": "^3.12.0"
nightwatch.conf.js
//Nightwatch Configuration
const seleniumServer = require('selenium-server')
const phantomjs = require('phantomjs-prebuilt')
const chromedriver = require('chromedriver')
const geckodriver = require('geckodriver')
require('nightwatch-cucumber')({
cucumberArgs: [
'--require-module', 'babel-core/register',
'--format', 'node_modules/cucumber-pretty',
'--require', 'hooks.js',
'--require', 'features/step_definitions',
'--format-options', '{"colorsEnabled":false}',
'--format', 'json:reports/cucumber.json',
'features'
],
nightwatchOutput: true
})
module.exports = {
// src_folders:'features',
output_folder: 'reports',
custom_assertions_path: '',
page_objects_path: 'page_objects/',
live_output: true,
disable_colors: false,
selenium: {
start_process: true,
server_path: seleniumServer.path,
log_path: '/reports',
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver' : geckodriver.path,
"webdriver.edge.driver" : "",
}
},
test_settings: {
default: {
launch_url: 'http://localhost',
selenium_port: 4444,
selenium_host: '127.0.0.1',
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
silent:false
//chromeOptions:['start-fullscreen']
},
selenium: {},
screenshots: {
enabled: true,
on_failure: true,
path: 'screenshots'
}
},
phantomjs: {
//launch_url: 'http://localhost/',
selenium_port: 4444,
selenium_host: '127.0.0.1',
desiredCapabilities: {
browserName: 'phantomjs',
javascriptEnabled: true,
acceptSslCerts: true,
//platform: 'Mac OS X',
"phantomjs.binary.path": phantomjs.path,
"phantomjs.cli.args" : ['--ignore-ssl-errors=true']
},
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
解决方案
推荐阅读
- mysql - mysqldump 使用终端 ubuntu 将数据库备份恢复到空数据库中
- spring - 春季休眠 OpenSessionInViewFilter
- java - JAVA 中的可搜索加密
- python - python, opencv 错误 cv.rectangle SystemError: old style getargs format uses new features
- c# - 当 CellEditingTemplate DataTemplate 控件更改其绑定值时,如何更新 CellTemplate DataTemplate 控件?
- javascript - && 运算符是否充当 if 条件?
- python - 在 Python 中计算 IRR
- python - 绘制五元宽边天线的辐射方向图
- mongodb - show dbs 和 show databases 之间的 MongoDB shell 区别
- java - 将项目添加到资源文件