nightwatchj.s 上的 Microsoft Edge 运行 "waitForElementVisible" 命令出错
Error while running "waitForElementVisible" command for Microsoft Edge on nightwatchj.s
当我在 Microsoft edge 中尝试 运行 测试时
浏览器启动并且页面正在加载,但随后出现错误:
TypeError:运行ning“waitForElementVisible”命令时出错:尝试为“/wd/hub/session/8bf67432a94d18e24f88493fd249c629/element/[object Object]/displayed”创建 HTTP 请求时出错:请求路径包含未转义的字符
对于 Chrome 和 Firefox 测试工作正常
测试码
module.exports = {
'Demo test Ecosia.org': function (browser) {
browser
.url('https://www.ecosia.org/')
.waitForElementVisible('body')
.assert.titleContains('Ecosia')
.assert.visible('input[type=search]')
.setValue('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.containsText('.mainline-results', 'Nightwatch.js')
.end();
}
};
我的nightwatch.conf.js
const seleniumServer = require('selenium-server');
const edgeDriver = require('edgedriver');
const chromeDriver = require('chromedriver');
const geckoDriver = require('geckodriver');
module.exports = {
src_folders: ['tests'],
custom_commands_path: '',
custom_assertions_path: '',
page_objects_path: '',
globals_path: '',
live_output: false,
disable_colors: false,
parallel_process_delay: 10,
"test_workers": {
"enabled": false,
"workers": "auto"
},
selenium: {
start_process: true,
//start_session: false,
server_path: seleniumServer.path,
check_process_delay: 5000,
host: '127.0.0.1',
port: 4144,
cli_args: {
"webdriver.ie.driver": ieDriver.path,
"webdriver.chrome.driver": chromeDriver.path,
"webdriver.gecko.driver": geckoDriver.path,
"webdriver.edge.driver": "node_modules/edgedriver_win64/msedgedriver.exe"
}
},
test_settings: {
skip_testcases_on_fail: false,
end_session_on_fail: false,
default: {
desiredCapabilities: {
browserName: 'chrome',
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: ['disable-gpu']
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true,
}
},
edge: {
desiredCapabilities: {
browserName: 'MicrosoftEdge',
javascriptEnabled: true,
acceptSslCerts: true
}
},
}
};
由于您使用的是基于铬的新Edge,我想您可以参考Chrome的相同设置。
使用 Chrome 时出现同样的错误可以通过添加 "w3c": false
来修复。因此,您可以添加以下行来修复 Edge Chromium 中的问题:
edgeOptions: { "w3c": false }
参考link:TypeError ERR_UNESCAPED_CHARACTERS on testing Vue project using Nightwatch
当我在 Microsoft edge 中尝试 运行 测试时 浏览器启动并且页面正在加载,但随后出现错误:
TypeError:运行ning“waitForElementVisible”命令时出错:尝试为“/wd/hub/session/8bf67432a94d18e24f88493fd249c629/element/[object Object]/displayed”创建 HTTP 请求时出错:请求路径包含未转义的字符
对于 Chrome 和 Firefox 测试工作正常 测试码
module.exports = {
'Demo test Ecosia.org': function (browser) {
browser
.url('https://www.ecosia.org/')
.waitForElementVisible('body')
.assert.titleContains('Ecosia')
.assert.visible('input[type=search]')
.setValue('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.containsText('.mainline-results', 'Nightwatch.js')
.end();
}
};
我的nightwatch.conf.js
const seleniumServer = require('selenium-server');
const edgeDriver = require('edgedriver');
const chromeDriver = require('chromedriver');
const geckoDriver = require('geckodriver');
module.exports = {
src_folders: ['tests'],
custom_commands_path: '',
custom_assertions_path: '',
page_objects_path: '',
globals_path: '',
live_output: false,
disable_colors: false,
parallel_process_delay: 10,
"test_workers": {
"enabled": false,
"workers": "auto"
},
selenium: {
start_process: true,
//start_session: false,
server_path: seleniumServer.path,
check_process_delay: 5000,
host: '127.0.0.1',
port: 4144,
cli_args: {
"webdriver.ie.driver": ieDriver.path,
"webdriver.chrome.driver": chromeDriver.path,
"webdriver.gecko.driver": geckoDriver.path,
"webdriver.edge.driver": "node_modules/edgedriver_win64/msedgedriver.exe"
}
},
test_settings: {
skip_testcases_on_fail: false,
end_session_on_fail: false,
default: {
desiredCapabilities: {
browserName: 'chrome',
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: ['disable-gpu']
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true,
}
},
edge: {
desiredCapabilities: {
browserName: 'MicrosoftEdge',
javascriptEnabled: true,
acceptSslCerts: true
}
},
}
};
由于您使用的是基于铬的新Edge,我想您可以参考Chrome的相同设置。
使用 Chrome 时出现同样的错误可以通过添加 "w3c": false
来修复。因此,您可以添加以下行来修复 Edge Chromium 中的问题:
edgeOptions: { "w3c": false }
参考link:TypeError ERR_UNESCAPED_CHARACTERS on testing Vue project using Nightwatch