I'm using nightwatch for testing my javascript application. I need to be able to run cross-browser tests on local machine. Chrome and Firefox are OK, but when running test on IE, I got an error:
Running: google
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 IningMessage.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modu
les\nightwatch\lib\http\request.js:150:16)
at IningMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
IEDriverServer is in version 2.45.0 as used selenium is. I'm using x64 version on 64b Windows 8.1. And I've already done the registry thing for IE11.
Test file:
module.exports = {
'google': function(browser){
return browser
.url('www.google')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
nightwatch.json:
{
"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
}
}
}
run mand:
nightwatch --env ie
It fails on this line:
.assert.urlContains('google')
For all help thanks in advance.
I'm using nightwatch for testing my javascript application. I need to be able to run cross-browser tests on local machine. Chrome and Firefox are OK, but when running test on IE, I got an error:
Running: google.
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 IningMessage.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modu
les\nightwatch\lib\http\request.js:150:16)
at IningMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
IEDriverServer is in version 2.45.0 as used selenium is. I'm using x64 version on 64b Windows 8.1. And I've already done the registry thing for IE11.
Test file:
module.exports = {
'google.': function(browser){
return browser
.url('www.google.')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
nightwatch.json:
{
"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
}
}
}
run mand:
nightwatch --env ie
It fails on this line:
.assert.urlContains('google')
For all help thanks in advance.
Share Improve this question edited Jun 6, 2015 at 9:43 DSDev7 asked Jun 6, 2015 at 9:38 DSDev7DSDev7 911 silver badge8 bronze badges3 Answers
Reset to default 7I see you've got a solution, but having been through this myself, I thought I'd leave this here for future people.
Selenium docs say Internet Explorer requires specific configuration
IEDriverServer needs to be in the path. My experience has been that using %PATH% is surprisingly flaky, and I either:
- set
webdriver.ie.driver
to a path in thecli_args
of nightwatch.json - start the Selenium Server by hand with
java -jar selenium-server-standalone-2.47.1.jar -Dwebdriver.ie.driver=.\IEDriverServer.exe
- set
Protected Mode in IE (Tools > Internet Options > Security) needs to be the same for all zones (as you've found!). I often test locally and on VMs, so I enabled it for Local and Trusted, rather than disable it for the Internet zone.
Set zoom to 100% (although, you know, why wouldn't it be?)
For IE10+, Enhanced Protected Mode needs to be disabled (Tools > Internet Options > Advanced > Security). Pretty sure this is disabled by default on client versions of Windows, but enabled on server versions.
For IE11+, do a reghack to facilitate the connection between the selenium server and the browser instance. In
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
add a DWORD foriexplore.exe
and set it to0
. If you're running 64-bit windows, that path beesHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
.
One extra from my experience:
- If you're on 64-bit windows, don't be tempted by the 64-bit IEDriverServer. It's slow. "Slower than the old lady in front of you at the ATM" slow.
I've solved this issue by disabling IE protected mode for all zones and also by lowering the security to lowest possible level for all zones as well.
I tried your test and it works fine on my laptop with Nightwatch v0.6.13. Which version of Nighwatch do you use ? (npm list nightwatch -g)