我找不到不包含整个Selenium罐子的野生动物园的任何有效的守夜人配置。守夜文件说明:
使用Selenium Standalone Server曾经是 管理各种浏览器驱动程序和服务,但从 不再需要Nightwatch 1.0,也不建议使用Nightwatch 1.0,除非 您正在针对旧版浏览器(例如Internet Explorer)进行测试。
野生动物园是否可以算作旧版浏览器?有人有一个可以运行的夜间守卫1.x配置文件示例,可以对野生动物园进行测试吗?
MacOS:High Sierra 10.13.6
Safari:12.0.2
夜间监视:v1.0.18
我当前的nightwatch.json(适用于Chrome浏览器,但不适用于Safari)
{
"src_folders": [
"__tests__/e2e/tests"
],
"output_folder": "__tests__/e2e/reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"webdriver": {
"start_process": true
},
"test_settings": {
"default": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"--window-size=1440,900"
]
}
}
},
"devChrome": {
"launch_url": "https://DEV_HOST",
"globals": {
"env": "dev"
},
"webdriver": {
"server_path": "node_modules/chromedriver/lib/chromedriver/chromedriver.exe",
"port": 9515
}
},
"devSafari": {
"launch_url": "https://DEV_HOST",
"globals": {
"env": "dev"
},
"webdriver": {
"server_path": "/usr/bin/safaridriver",
"port": 9515
}
}
}
}
运行devSafari配置时遇到的当前错误: 无法启动服务器:必须至少指定一个配置参数。
答案 0 :(得分:1)
从GitHub(https://github.com/nightwatchjs/nightwatch-docs/issues/94)上的守夜人小组获得了一些帮助,我现在有了Nightwatch 1.x和Safari 10+的工作示例配置文件。注意:“工作”是指浏览器打开,并且我可以看到Nightwatch与之交互。测试实际上并没有通过Chrome的方式,但是最有可能的原因是浏览器之间的细微差别可以在测试用例中解决。
{
"src_folders": [
"__tests__/e2e/tests"
],
"output_folder": "__tests__/e2e/reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"webdriver": {
"start_process": true,
"server_path": "/usr/bin/safaridriver",
"port": 4445
},
"test_settings": {
"default": {
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"safari": {
"launch_url": "localhost",
"desiredCapabilities": {
"browserName":"safari"
},
"globals": {
"env": "dev"
}
}
}
}
/usr/bin/safaridriver --enable
答案 1 :(得分:0)
在Safari 10+中,您只需要使用safari
作为browserName
。然后确保在运行测试时指定正确的环境。对于我的配置,这意味着传递选项--env safari
。这是我的nightwatch.conf.js:
module.exports = {
src_folders: ['tests/e2e/specs'],
output_folder: 'tests/e2e/reports',
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'WebDriver.chrome.driver': require('chromedriver').path,
},
},
test_settings: {
chrome: {
desiredCapabilities: {
browserName: 'chrome',
},
},
safari: {
desiredCapabilities: {
browserName: 'safari',
javascriptEnabled: true,
acceptSslCerts: true,
},
},
},
}