我尝试使用Vue CLI设置Nightwatch环境时遇到问题。此时,我只想使其与Chrome一起使用(我们将很快在Firefox中看到它),但是当我运行简单的测试时,它不起作用。
这是我的测试文件:
module.exports = {
'default e2e tests': browser => {
browser
.url("http://localhost:8080")
.waitForElementVisible('#app', 5000)
.assert.ok(true)
.end()
}
}
引发以下错误:
运行.isElementDisplayed()协议操作时出错:TypeError[ERR_UNESCAPED_CHARACTERS]:尝试创建HTTP请求时出错用于“ / wd / hub / session / 28a21f6ed7009d54e70663e3ed407eb6 / element / [object对象] /显示“:请求路径包含未转义的字符在新的ClientRequest(_http_client.js:115:13)在Object.request(http.js:42:10)在HttpRequest.createHttpRequest(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ http \ request.js:138:55)在HttpRequest.send(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ http \ request.js:217:29)在Promise(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ transport \ transport.js:193:15)在新的Promise()在Selenium2Protocol.sendProtocolAction(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ transport \ transport.js:191:12)在Selenium2Protocol.runProtocolAction(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ transport \ jsonwire.js:61:17)在Object.isElementDisplayed(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ transport \ actions.js:54:10)在Selenium2Protocol.executeProtocolAction(C:\ Users \ john.doe \ Desktop \Développement\ App \ vue \ node_modules \ nightwatch \ lib \ transport \ transport.js:239:48)
我提供有效的选择器时出现此错误。我尝试使用不存在的选择器,在这种情况下,我得到一个简单的... expected "visible" but got: "not found"
。
这是我的Nightwatch配置文件:
module.exports = {
"src_folders": ["tests/e2e/specs"],
"output_folder": "tests/e2e/reports",
"page_objects_path": "tests/e2e/page-objects",
"custom_assertions_path": "tests/e2e/custom-assertions",
"custom_commands_path": "tests/e2e/custom-commands",
"test_workers": {
"enabled": true,
"workers": "auto"
},
"selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar",
"log_path" : "tests/e2e/logs",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
}
},
"test_settings" : {
"default" : {
"launch_url": 'https://www.google.com',
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": true,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"w3c": false
}
},
"webdriver": {
"use_legacy_jsonwire": false
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"alwaysMatch": {
"acceptInsecureCerts": true,
"moz:firefoxOptions": {
"args": []
}
}
}
}
}
};
关于可能导致此错误的任何想法?
让我知道是否应该提供例如node_modules文件夹中的其他文件。
通过Estus Flask的链接解决了我的问题:
只需在默认配置中添加此行
"chromeOptions": {
"w3c": false
}