【发布时间】:2021-05-12 13:06:23
【问题描述】:
我正在使用 Nightwatch、Selenium 和 Chrome 驱动程序进行自动化 UI 测试。有时在任意数量的远程环境中都会出现测试失败。为了在本地调试故障,我想在测试失败时保持浏览器打开。
我以前可以使用 nightwatch.json 和 nightwatch.conf.js 中的配置设置来做到这一点,但我在硬盘驱动器故障中丢失了我的配置设置备忘单,尽管我在谷歌上尽了最大努力,但我还是可以'似乎又找不到合适的组合了。
如果我没记错的话,它不是任何类型的 keepBrowserOpen: true 类型标志。如果没有记错的话,它是某种类型的超时设置为一个愚蠢的高数字,并结合了诸如 detachDriver 之类的其他东西。我检查了 Selenium 文档,特别关注 Chrome Driver Options 和 Chrome Driver options 的列表,但我没有找到任何有效的组合。
我错过了什么?
这是我的 nightwatch.json
{
"output_folder": "tests/automation/reports",
"end_session_on_fail": false,
"test_settings": {
"default": {
"selenium_port": 4444,
"screenshots": {
"enabled": true,
"path": "tests/automation/reports/screenshots"
},
"javascriptEnabled": true,
"acceptSslCerts": true,
"acceptInsecureCerts": true,
"globals": {
"waitForConditionTimeout": 10000
}
},
"chrome": {
"extends": "default",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"acceptInsecureCerts": true,
"chromeOptions": {
"args": [
"--no-sandbox",
"--disable-gpu"
]
}
}
}
}
}
还有我的 nightwatch.conf.js
const geckoDriver = require('geckodriver');
const chromeDriver = require('chromedriver');
const seleniumServer = require('selenium-server');
module.exports = (function (settings) {
settings.selenium = {
start_process: true,
server_path: seleniumServer.path,
log_path: 'tests/automation/reports/',
host: 'localhost',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromeDriver.path,
'webdriver.gecko.driver': geckoDriver.path,
'webdriver.edge.driver': 'C:\\windows\\system32\\MicrosoftWebDriver.exe',
'webdriver.port': '4444'
}
};
return settings;
})(require('./nightwatch.json'));
Selenium 版本是 2.35.1
【问题讨论】:
标签: selenium selenium-webdriver selenium-chromedriver nightwatch.js