运行 在 Firefox 中使用 Nightwatch 进行测试无法连接到 Selenium 服务器
Running test with Nightwatch in Firefox fails to connect to Selenium server
我正在尝试使用 Nightwatch.js 对网站进行自动化测试,我使用的是 macOS High Sierra。
因此,我开始按照文档中所述使用 Selenium Standalone Server 进行测试。
chrome 测试效果很好,我没有问题。但我似乎无法让 Firefox 测试工作,我一直在网上测试和搜索修复程序,但我放弃了,因为我找到的解决方案中 none 有效。
这是我的 nightwatch.json 配置文件。
{
"src_folders": [
"test"
],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./bin/selenium-server-standalone-3.13.0.jar",
"log_path": "",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./bin/chromedriver",
"webdriver.gecko.driver": "./bin/geckodriver",
"webdriver.firefox.profile": "nightwatch"
}
},
"test_settings": {
"default": {
"launch_url": "https://www.google.com",
"selenium_port": 4444,
"selenium_host": "127.0.0.1",
"default_path_prefix": "",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"marionette": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--load-extension=/Users/jackch/Downloads/chrome, --url-base=/wd/hub"
]
}
}
}
}
}
然后当我在终端中 运行 nightwatch -e --verbose
时,我得到了同样的错误 Error retrieving a new session from the selenium server Connection refused! Is selenium server started?
。
我尝试了很多东西:
1) 我在默认端口 4444 上的单独终端中启动了 geckodriver,以下是 geckodriver 的日志:
2018-07-23 12:09:03.432 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7903, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.559 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7943, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.624 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7b37, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.713 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7bcf, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1532336943850 Marionette INFO Listening on port 52869
2018-07-23 12:09:04.333 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d07, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:04.413 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d83, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2) 然后我尝试更改 geckodriver
的端口,因为我认为它们可能会干扰,因为 Selenium 和 gecko 都选择了 4444 端口,但没有任何改变。
3) 我尝试单独启动 Selenium 服务器,然后将其链接。这意味着我在 nightwatch.json 中将 "start_process"
设置为 false。而且我还是没成功。
这是我 运行 nightwatch -e --verbose
:
之后的完整消息
Starting selenium server... started - PID: 28112
[Test] Test Suite
=====================
Running: Login
INFO Request: POST /session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true,"name":"Test"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":145}
INFO Response 200 POST /session (1721ms) { value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 } } } }
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: [Object] } } }
感谢您提供的任何帮助。
我 运行 在 mac os high sierra 在 firefox、safari、chrome 上守夜。在 window 歌剧、IE 上。
我的配置:
module.exports = {
"src_folders": ["tests"],
"output_folder": "reports",
// "live_output" : true,
// "parallel_process_delay" : 1500,
"custom_commands_path": "commands",
"custom_assertions_path": "assertions",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./node_modules/nightwatch/lib/sel-serv.jar",
"log_path": "selenium_logs",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/.bin/chromedriver",
"webdriver.gecko.driver": "./node_modules/.bin/geckodriver",
"webdriver.edge.driver": "./node_modules/.bin/edgedriver",
"webdriver.ie.driver": "drivers/IEDriverServer.exe",
"webdriver.opera.driver": "drivers/operadriver.exe",
"webdriver.safari.driver": "/usr/bin/safaridriver"
}
},
"test_settings": {
"default": {
"selenium_port": 4444,
"selenium_host": "localhost",
"default_path_prefix": "/wd/hub",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "tmp_screenshots"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true,
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "firefox",
"user": "me1",
"pass": "test"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"disable-web-security",
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "chrome",
"user": "me1",
"pass": "test"
}
},
"opera": {
"desiredCapabilities": {
"browserName": "opera",
"operaOptions": {
"binary": "C://Program Files//Opera//53.0.2907.68//opera.exe"
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "opera",
"user": "me4",
"pass": "test"
}
},
"ie": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": 11,
"allowBlockedContent": true,
"javascriptEnabled": true,
"acceptSslCerts": true,
"ignoreProtectedModeSettings": true
},
"globals": {
"type": "ie",
"user": "me3",
"pass": "test"
}
},
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
},
"globals": {
"type": "safari",
"user": "me3",
"pass": "test"
}
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
}
};
我正在尝试使用 Nightwatch.js 对网站进行自动化测试,我使用的是 macOS High Sierra。 因此,我开始按照文档中所述使用 Selenium Standalone Server 进行测试。 chrome 测试效果很好,我没有问题。但我似乎无法让 Firefox 测试工作,我一直在网上测试和搜索修复程序,但我放弃了,因为我找到的解决方案中 none 有效。 这是我的 nightwatch.json 配置文件。
{
"src_folders": [
"test"
],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./bin/selenium-server-standalone-3.13.0.jar",
"log_path": "",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./bin/chromedriver",
"webdriver.gecko.driver": "./bin/geckodriver",
"webdriver.firefox.profile": "nightwatch"
}
},
"test_settings": {
"default": {
"launch_url": "https://www.google.com",
"selenium_port": 4444,
"selenium_host": "127.0.0.1",
"default_path_prefix": "",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"marionette": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--load-extension=/Users/jackch/Downloads/chrome, --url-base=/wd/hub"
]
}
}
}
}
}
然后当我在终端中 运行 nightwatch -e --verbose
时,我得到了同样的错误 Error retrieving a new session from the selenium server Connection refused! Is selenium server started?
。
我尝试了很多东西:
1) 我在默认端口 4444 上的单独终端中启动了 geckodriver,以下是 geckodriver 的日志:
2018-07-23 12:09:03.432 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7903, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.559 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7943, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.624 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7b37, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.713 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7bcf, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1532336943850 Marionette INFO Listening on port 52869
2018-07-23 12:09:04.333 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d07, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:04.413 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d83, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2) 然后我尝试更改 geckodriver
的端口,因为我认为它们可能会干扰,因为 Selenium 和 gecko 都选择了 4444 端口,但没有任何改变。
3) 我尝试单独启动 Selenium 服务器,然后将其链接。这意味着我在 nightwatch.json 中将 "start_process"
设置为 false。而且我还是没成功。
这是我 运行 nightwatch -e --verbose
:
Starting selenium server... started - PID: 28112
[Test] Test Suite
=====================
Running: Login
INFO Request: POST /session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true,"name":"Test"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":145}
INFO Response 200 POST /session (1721ms) { value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 } } } }
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: [Object] } } }
感谢您提供的任何帮助。
我 运行 在 mac os high sierra 在 firefox、safari、chrome 上守夜。在 window 歌剧、IE 上。 我的配置:
module.exports = {
"src_folders": ["tests"],
"output_folder": "reports",
// "live_output" : true,
// "parallel_process_delay" : 1500,
"custom_commands_path": "commands",
"custom_assertions_path": "assertions",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./node_modules/nightwatch/lib/sel-serv.jar",
"log_path": "selenium_logs",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/.bin/chromedriver",
"webdriver.gecko.driver": "./node_modules/.bin/geckodriver",
"webdriver.edge.driver": "./node_modules/.bin/edgedriver",
"webdriver.ie.driver": "drivers/IEDriverServer.exe",
"webdriver.opera.driver": "drivers/operadriver.exe",
"webdriver.safari.driver": "/usr/bin/safaridriver"
}
},
"test_settings": {
"default": {
"selenium_port": 4444,
"selenium_host": "localhost",
"default_path_prefix": "/wd/hub",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "tmp_screenshots"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true,
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "firefox",
"user": "me1",
"pass": "test"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"disable-web-security",
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "chrome",
"user": "me1",
"pass": "test"
}
},
"opera": {
"desiredCapabilities": {
"browserName": "opera",
"operaOptions": {
"binary": "C://Program Files//Opera//53.0.2907.68//opera.exe"
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "opera",
"user": "me4",
"pass": "test"
}
},
"ie": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": 11,
"allowBlockedContent": true,
"javascriptEnabled": true,
"acceptSslCerts": true,
"ignoreProtectedModeSettings": true
},
"globals": {
"type": "ie",
"user": "me3",
"pass": "test"
}
},
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
},
"globals": {
"type": "safari",
"user": "me3",
"pass": "test"
}
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
}
};