Tunnel Examples
This guide provides practical examples for configuring TestingBot Tunnel to suit your testing needs.
Getting Started
First, download the TestingBot Tunnel and start it from the command line:
java -jar testingbot-tunnel.jar key secret
Then update your test configuration to route traffic through the tunnel by changing the hub URL:
Before (direct connection):
urlhub = "http://key:secret@hub.testingbot.com/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
After (through tunnel):
urlhub = "http://key:secret@localhost:4445/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
By connecting to localhost:4445, all test commands are routed through the tunnel to TestingBot.
Tunnel Identifiers
Tunnel identifiers allow you to run multiple tunnels simultaneously and direct specific tests to a particular tunnel. This is useful for parallel testing or when different tests require different tunnel configurations.
Start a tunnel with an identifier using the -i flag:
java -jar testingbot-tunnel.jar key secret -i myTunnel
Then specify the identifier in your test's desired capabilities:
{
"browserName": "firefox",
"browserVersion": "latest",
"platformName": "WIN11",
"tunnel-identifier": "myTunnel"
}
Custom Headers
Inject custom HTTP headers into all requests made through the tunnel. This is useful for authentication tokens, feature flags, or debugging headers.
java -jar testingbot-tunnel.jar key secret \
--extra-headers '{"MyOwnHeader": "HeaderValue"}'
Upstream Proxy
Route tunnel traffic through an upstream proxy server. Common use cases include:
- Corporate networks that require all traffic to pass through a proxy
- Geo-location testing using proxies in different regions
Use the -Y flag to specify the proxy address and port. If the proxy requires authentication, add credentials with -z:
java -jar testingbot-tunnel.jar key secret -Y myproxy:9000 -z username:password
Shared Tunnels
By default, tunnels are only accessible to your user account. Enable the --shared flag to allow other team members to use your tunnel:
java -jar testingbot-tunnel.jar key secret --shared
Team members can then connect to the shared tunnel without starting their own.
Basic Authentication
Automatically supply credentials for websites that require HTTP Basic Authentication. The tunnel will inject these credentials for matching hosts, so your tests don't need to handle authentication dialogs.
Use the -a flag with the format host:port:username:password. For standard HTTP sites, use port 80:
java -jar testingbot-tunnel.jar key secret -a mywebsite.com:80:myusername:mypassword