Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (31 sloc) 1.08 KB
title publishedDate subline tags
Selenium-webdriver and HTTP CONNECT tunneling
2017-02-17T21:43
Boring tunnel machine.
selenium, testing

If you are running selenium-webdriver within an environment that requires an HTTPS proxy to connect to the outside world in order to drive your tests, such as when using the Browserstack webdriver hub, then you may need to configure a webdriver proxy with an HTTP CONNECT tunneling httpAgent, like so:

import { Builder } from 'selenium-webdriver';
import { httpsOverHttp } from 'tunnel-agent';
import url from 'url';

# other stuff ...
const proxyUrl = url.parse(process.env.HTTP_PROXY);

driver = new Builder()
  .usingServer('https://hub.browserstack.com/wd/hub')
  .withCapabilities({ ... })
  .usingHttpAgent(httpsOverHttp({
    proxy: {
      host: proxyUrl.hostname,
      port: proxyUrl.port
    }
  }))
  .build();