我正在使用Selenium WebDriver API的节点封装程序Nightwatch构建一套自动化集成测试。我能够正常使用Chrome,但不适用于Firefox(或Safari,对此)。当使用Nightwatch和Selenium测试本地主机时,无法在Firefox上加载页面
我认为这个问题与GeckoDriver与Firefox驱动程序有关。我已配置Nightwatch在我的nightwatch.json
中使用GeckoDriver。但Selenium似乎在寻找基于终端输出nightwatch -e firefox --verbose
的Firefox Driver。请看下图:
INFO Request: POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url
- data: {"url":"localhost:9000"}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":24}
ERROR Response 500 POST /wd/hub/session/2c156cf4-10cb-44b2-8b1f-c12312b4633f/url (1218ms) { state: 'unknown error',
sessionId: '2c156cf4-10cb-44b2-8b1f-c12312b4633f',
hCode: 1111219279,
value:
{ additionalInformation: '\nDriver info: org.openqa.selenium.firefox.FirefoxDriver\nCapabilities ...
这里是我的Nightwatch配置文件:
{
"src_folders": ["./nightwatch/tests"],
"output_folder": "./nightwatch/reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "./nightwatch/tests/pages",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./nightwatch/selenium-server-standalone-3.4.0.jar",
"log_path": false,
"cli_args": {
"webdriver.chrome.driver": "./nightwatch/drivers/chromedriver",
"webdriver.gecko.driver": "./nightwatch/drivers/geckodriver"
}
},
"test_settings": {
"default": {
"desiredCapabilities": {
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true
}
}
}
}
和良好的措施,这里是nightwatch/pages/index.js
文件我试图访问在我的测试:
module.exports = {
url: 'localhost:9000',
elements: {
// stuff
}
}