我是NightWatch的新手,所以我遵循了一些教程,做了他们所说的一切,但是现在我得到了一个空白页,标题为“ data;”,而不是我想看到的页面“ {{ 3}}”。
这是json文件。似乎此问题与json配置有关。有什么帮助吗?非常感谢!
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"selenium": {
"start_process": true,
"start_session" : true,
"server_path": "C:\\Users\\Esau Alvarez\\Desktop\\selenium-server-standalone-3.13.0.jar",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "C:\\Users\\Esau Alvarez\\Desktop\\chromedriver.exe"
}
},
"test_settings" : {
"default": {
"launch_url": "https://www.gandhi.com.mx/",
"screenshots": {
"enabled": false
},
"desiredCapabilities": {
"browserName": "chrome",
"marionette": true
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"webdriver": {
"server_path": "C:\\Users\\Esau Alvarez\\Desktop\\NightWatch\\chromedriver.exe"
}
}
}
}
}
这是我的测试文件
module.exports = {
"Test": function (browser) {
browser
.windowMaximize()
.url("https://www.gandhi.com.mx/")
.waitForElementVisible('body', 1000)
}
}
答案 0 :(得分:0)
{ "src_folders": ["tests"], "output_folder": "reports", "selenium": { "start_process": true, "start_session": true, "server_path": "C:\\Users\\Esau Alvarez\\Desktop\\selenium-server-standalone-3.13.0.jar", "port": 4444, "cli_args": { "webdriver.chrome.driver": "C:\\Users\\Esau Alvarez\\Desktop\\chromedriver.exe", "webdriver.gecko.driver": "Path to gecko driver.exe" } }, "test_settings": { "default": { "launch_url": "https://www.gandhi.com.mx/", "screenshots": { "enabled": false }, "desiredCapabilities": { "browserName": "firefox", "marionette": true } }, "chrome": { "desiredCapabilities": { "browserName": "chrome" } } } }
也请增加等待时间,例如2000或3000,以便“安全”可见,以确保安全。
module.exports = {
"Test": function (browser) {
browser
.windowMaximize()
.url("https://www.gandhi.com.mx/")
.waitForElementVisible('body', 3000)
}
}
因此,根据nightwatch json,您的默认执行应在firefox中进行。如果要在chrome上执行相同操作,则应使用chrome键盘或将chrome配置移动到默认部分。