Search code examples
javascriptproxynightwatch.jsbrowserstack

BrowserStack + Nightwatch.js How to set up proxy which is password protected (ERROR: httpProxy was not of the form host[:port]


BrowserStack + Nightwatch.js How to set up proxy which is password protected

  common_capabilities: {
    'browserstack.user': 'user',
    'browserstack.key': 'key',
    'browserstack.debug': true,
},
test_settings: {
    default: {
        desiredCapabilities: {
            'os': 'OS X',
            'os_version': 'Sierra',
            'browser': 'Firefox',
            'browser_version': '53.0',
            'resolution': '1280x960',
            "acceptSslCerts": 'false',
            'proxy': {
                'httpProxy': 'user:password@server:80',
                'protocol': 'http',
                'proxyType': 'manual',
                //'httpProxy': 'server:80',
                //'user': 'user',
                //'pass': 'password'
            }
        },

I have en ERROR:
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?

message: 'Could not start Browser / Emulator
Reason: httpProxy was not of the form host[:port]


Solution

  • BrowserStack Support asked me to provide my solution based on the specifics of my setup: I had to use BrowserStack.local

      "scripts": { 
          "test": "./bin/BrowserStackLocal --key ACCESS_KEY --local-proxy-host PROXY_HOST --local-proxy-port PROXY_PORT --local-proxy-user PROXY_USER --local-proxy-pass PROXY_PASS --local-identifier Test123 & ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests", 
          "local": "./bin/BrowserStackLocal --key ACCESS_KEY --local-identifier Test123 && ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests",
          "nightwatch": "./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests"
      },
    

    1st step: launching BrowserStackLocal through Proxy (in one Terminal's window 2nd step: run tests in "tests" folder