Skip to main content

Examples

Below you will find some examples on how to use the Tunnel.

To start your Tunnel, download the Java based Tunnel and run from the commandline:

java -jar testingbot-tunnel.jar key secret

Below you will find an example demonstrating how to adjust your tests to use the Tunnel.

Before:
urlhub = "http://key:secret@hub.testingbot.com/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
After:
urlhub = "http://key:secret@localhost:4445/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new

Notice how we now use localhost:4445, which will send the test commands through the Tunnel.

Tunnel Identifiers

You can choose to use a tunnel identifier to connect to a specific tunnel.

For example, launch a tunnel:

java -jar testingbot-tunnel.jar key secret -i myTunnel

This tunnel now has an identifier "myTunnel". You can instruct your tests to go through this specific tunnel with Desired Capabilities:

{
	"browserName":"firefox", 
	"version":"latest", 
	"platform":"WIN10", 
	"tunnel-identifier":"myTunnel"
}

Adding Extra Headers

TestingBot tunnel allows you to add extra headers to the HTTP requests it will make during testing.

For example, to add a custom header:
java -jar testingbot-tunnel.jar key secret \
--extra-headers '{"MyOwnHeader": "HeaderValue"}'

Upstream Proxy

You can instruct TestingBot Tunnel to use a specific upstream proxy.
For example, your company network requires all traffic to go through a specific proxy.
Or, you'd like to do geo-location testing and want to use a proxy in a different geographical location.

You can specify -Y address:port to indicate which proxy you'd like to use.
If your proxy requires authentication, you can pass the credentials with:

-z username:password
For example:
java -jar testingbot-tunnel.jar key secret -Y myproxy:9000 -z username:password

Basic Authentication

If you need to test a website or pages that require Basic Authentication, then you can instruct TestingBot tunnel to automatically enter the correct credentials during testing.

You can specify -a host:port:user:passwd to indicate which credentials to use for which host (+port).
If your website is not running on a specific port, you can use port 80.

java -jar testingbot-tunnel.jar key secret -a mywebsite.com:80:myusername:mypassword
Was this page helpful?

Looking for More Help?

Have questions or need more information?
You can reach us via the following channels: