Proxy Setup
You can tunnel two different types of request through a proxy:
- connection between your test script and the browser driver (or WebDriver endpoint)
- connection between the browser and the internet
Proxy Between Driver And Test
If your company has a corporate proxy (e.g. on http://my.corp.proxy.com:9090
) for all outgoing requests, follow the below steps to install and configure global-agent.
Install global-agent
- npm
- Yarn
- pnpm
npm install global-agent --save-dev
yarn add global-agent --dev
pnpm add global-agent --save-dev
Add global-agent bootstrap to your config file
Add the following require statement to the top of your config file.
wdio.conf.js
import { bootstrap } from 'global-agent';
bootstrap();
export const config = {
// ...
}
Set global-agent environment variables
Before you start the test, make sure you've exported the variable in the terminal, like so:
export GLOBAL_AGENT_HTTP_PROXY=http://my.corp.proxy.com:9090
wdio wdio.conf.js
You can exclude URLs from the proxy by exporting the variable, like so:
export GLOBAL_AGENT_HTTP_PROXY=http://my.corp.proxy.com:9090
export GLOBAL_AGENT_NO_PROXY='.foo.com'
wdio wdio.conf.js
If necessary, you can specify GLOBAL_AGENT_HTTPS_PROXY
to route HTTPS traffic through a different proxy than HTTP traffic.
export GLOBAL_AGENT_HTTP_PROXY=http://my.corp.proxy.com:9090
export GLOBAL_AGENT_HTTPS_PROXY=http://my.corp.proxy.com:9091
wdio wdio.conf.js