DSDev7
DSDev7

Reputation: 91

nightwatch.js internet explorer

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.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)

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.com': function(browser){
        return browser
            .url('www.google.com')
            .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 command:

nightwatch --env ie

It fails on this line:

.assert.urlContains('google')

For all help thanks in advance.

Upvotes: 2

Views: 4683

Answers (3)

Dan Caseley
Dan Caseley

Reputation: 569

I 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 the cli_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
  • 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 for iexplore.exe and set it to 0. If you're running 64-bit windows, that path becomes HKEY_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.

Upvotes: 7

DSDev7
DSDev7

Reputation: 91

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.

Upvotes: 2

Nicolas Pennec
Nicolas Pennec

Reputation: 7631

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)

Upvotes: 0

Related Questions