Nightwatch with remoteWebDriver and a virtual machine.

611 views
Skip to first unread message

Chris Neale

unread,
Oct 29, 2014, 9:51:39 AM10/29/14
to nightw...@googlegroups.com
I'm having a go at getting Nightwatch to test a site in IE6 on a virtual machine. Has anyone had a go at doing this before? Sharing a nightwatch.json config and/or any hints would be very handy. :)

Lacy Morrow

unread,
Oct 29, 2014, 3:35:59 PM10/29/14
to nightw...@googlegroups.com
Most of my testing is done in VMs. I normally support IE8+ so don't bother testing on IE6/7, but I was interested to see if my current tests would work in IE6.

I booted a VM, installed Java (v7, which is available until april) and NodeJS and ran npm install (had to fix a path issue immediately).

I chose a relatively straightforward test that was written for IE8 and it ran perfectly, even though the site itself looks like a wreck (doesn't support IE6) and passed after one tweak:

I ran into the same security certificate issue that I faced in IE8, but IE6 creates a pop-up alert instead of a web page. In IE8 I bypass that page with this hack:
    browser
      .url(browser.globals.baseURL)
      // Bypass IE8 Certificate Security Error
      .getTitle(function(title) {
        if(title.indexOf('Certificate Error') !== -1) {
          this.url('javascript:document.getElementById("overridelink").click();');
        }
      })

To bypass the security error in IE6 I just added one line:

    browser
      .url(browser.globals.baseURL)
      // Bypass IE6 Certificate Security Error
      .acceptAlert()
      // Bypass IE8 Certificate Security Error
      .getTitle(function(title) {
        if(title.indexOf('Certificate Error') !== -1) {
          this.url('javascript:document.getElementById("overridelink").click();');
        }
      })

In my limited testing (firefox) this line doesn't seem to affect any other browsers, I assume the acceptAlert call does not "fail" if the alert doesn't exist. After this fix my test ran perfectly.

Lacy Morrow

unread,
Oct 29, 2014, 3:37:05 PM10/29/14
to nightw...@googlegroups.com
Here is a nightwatch.json:

{
  "src_folders" : ["nightwatch"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "globals_path" : "globals_stg.js",
  "live_output": false,

  "selenium" : {
    "start_process" : true,
    "server_path" : "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.43.1.jar",
    "log_path" : "logs",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "chromedriver.exe",
      "webdriver.ie.driver" : "IEDriverServer.exe"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost/",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent" : true,
      "screenshots" : {
        "enabled" : true,
        "path" : "./screenshots/"
      },
      "desiredCapabilities": {
        "browserName": "internet explorer",
        "elementScrollBehavior": 1,
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "ie" : {
      "desiredCapabilities": {
        "browserName": "internet explorer",
        "elementScrollBehavior": 1,
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "safari" : {
      "desiredCapabilities": {
        "browserName": "safari",
        "elementScrollBehavior": 1,
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "chromeOptions": {
          "args":["disable-web-security", "ignore-certificate-errors"]
        }
      }
    },
    "firefox" : {
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}

Reply all
Reply to author
Forward
0 new messages