Javascript nightwatch.js internet explorer
我正在使用nightwatch测试我的javascript应用程序。我需要能够在本地计算机上运行跨浏览器测试。Chrome和Firefox还可以,但在IE上运行测试时,我遇到了一个错误:Javascript nightwatch.js internet explorer,javascript,selenium,e2e-testing,nightwatch.js,Javascript,Selenium,E2e Testing,Nightwatch.js,我正在使用nightwatch测试我的javascript应用程序。我需要能够在本地计算机上运行跨浏览器测试。Chrome和Firefox还可以,但在IE上运行测试时,我遇到了一个错误: Running: google.com TypeError: undefined is not a function at pass (C:\Users\Dávid\AppData\Roaming\npm\node_modules\nightwatch\lib\api\ assertions\
Running: google.com
TypeError: undefined is not a function
at pass (C:\Users\Dávid\AppData\Roaming\npm\node_modules\nightwatch\lib\api\
assertions\urlContains.js:23:18)
at Object.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\night
watch\lib\core\assertion.js:94:23)
at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:299:20)
at HttpRequest.emit (events.js:110:17)
at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:346:15)
at HttpRequest.emit (events.js:118:17)
at IncomingMessage.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modu
les\nightwatch\lib\http\request.js:150:16)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
nightwatch.json:
module.exports = {
'google.com': function(browser){
return browser
.url('www.google.com')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
{
"src_folders" : ["./tests/e2e"],
"output_folder" : "./tests/reports",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "./bin/IEDriverServer.exe",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:3001",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome": {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"ie": {
"desiredCapabilities": {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
nightwatch --env ie
.assert.urlContains('google')
运行命令:
module.exports = {
'google.com': function(browser){
return browser
.url('www.google.com')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
{
"src_folders" : ["./tests/e2e"],
"output_folder" : "./tests/reports",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "./bin/IEDriverServer.exe",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:3001",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome": {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"ie": {
"desiredCapabilities": {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
nightwatch --env ie
.assert.urlContains('google')
这一行失败:
module.exports = {
'google.com': function(browser){
return browser
.url('www.google.com')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
{
"src_folders" : ["./tests/e2e"],
"output_folder" : "./tests/reports",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "./bin/IEDriverServer.exe",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:3001",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome": {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"ie": {
"desiredCapabilities": {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
nightwatch --env ie
.assert.urlContains('google')
感谢您的帮助。我尝试了您的测试,它在我的笔记本电脑Nightwatch v0.6.13上运行良好。你使用哪个版本的Nighwatch?(npm list nightwatch-g)我通过禁用所有区域的IE保护模式,并将所有区域的安全性降低到最低级别,解决了这个问题。我知道你已经找到了解决方案,但我自己也经历了这一点,我想我会把这个留给未来的人 假设Internet Explorer需要特定的配置
- IEDriverServer需要位于路径中。我的经验是,使用%PATH%令人惊讶地不可靠,我:
- 将
设置为nightwatch.json的webdriver.ie.driver
中的路径cli_args
- 使用
java-jar Selenium-Server-standalone-2.47.1.jar-Dwebdriver.ie.driver=。\IEDriverServer.exe
- 将
- IE中的受保护模式(工具>Internet选项>安全性)对于所有区域都需要相同(正如您所发现的!)。我经常在本地和虚拟机上进行测试,所以我为本地和受信任启用了它,而不是为Internet区域禁用它
- 将缩放设置为100%(尽管,你知道,为什么不呢?)
- 对于IE10+,需要禁用增强的保护模式(工具>Internet选项>高级>安全)。可以肯定的是,这在Windows的客户端版本上默认是禁用的,但在服务器版本上是启用的
- 对于IE11+,执行reghack以促进selenium服务器和浏览器实例之间的连接。在
中,为HKEY\u LOCAL\u MACHINE\SOFTWARE\Microsoft\internetexplorer\Main\FeatureControl\FEATURE\u BFCACHE
添加一个DWORD,并将其设置为iexplore.exe
。如果您运行的是64位windows,则该路径将变为0
HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE\u BFCACHE
- 如果您使用的是64位windows,请不要被64位IEDriverServer所诱惑。很慢。“比自动取款机前面的老太太慢”慢