【发布时间】:2017-04-21 23:51:05
【问题描述】:
我正在使用 Nightwatch(Selenium WebDriver API 的节点包装器)构建一套自动化集成测试。我能够让它在 Chrome 上正常工作,但不能在 Firefox(或 Safari,就此而言)。
我认为问题与 GeckoDriver 与 Firefox 驱动程序有关。我已将 Nightwatch 配置为在我的 nightwatch.json 中使用 GeckoDriver。但是 Selenium 似乎正在寻找 Firefox 驱动程序,基于nightwatch -e firefox --verbose 的终端输出。见下文:
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
}
}
【问题讨论】:
标签: firefox selenium-webdriver nightwatch.js geckodriver