Tag: "proxy"

TestingBot and BrowserMob Proxy

Today we have added support for using a BrowserMob proxy together with our Selenium grid.

By using this proxy, you can manipulate HTTP traffic during your tests, and do some other cool things too:

  • Simulate network latency/traffic
  • Capture performance data in HAR files
  • Rewrite HTTP requests and responses
  • Set and get HTTP headers

We provide a private and secure proxy for every customer, free of charge.
The traffic flowing through this proxy will only be available to you.

Below is an example on how to start and use a proxy.

Starting a new Proxy

To start a proxy, please make a GET request to our API

curl -u API_KEY:API_SECRET http://api.testingbot.com/v1/tunnel

We will boot up a pristine virtual machine for you, which should take no longer than 45 seconds.
Once the machine is booted, make the same request again to obtain the IP address of your personal VM.
Now that you have the IP, you can start using the proxy and do some interesting things.

Use the proxy

In this example, we’ll capture performance data in a HAR file for a single Selenium test in Ruby.

Start off by creating a listener on a free port:

curl -X POST http://IP:9090/proxy

This call will return a free port (for example 9091), which you need to use in your test.
Also, create a HAR attached to the port you obtained:

curl -x PUT http://IP:9090/proxy/9091/har

Now run the test with your proxy:

#!/usr/bin/env ruby
require "rubygems"
require 'testingbot'
gem "selenium-webdriver"
require "selenium-webdriver"

caps = {
  :browserName => "firefox",
  :version => "10",
  :platform => "WINDOWS",
  :proxy => Selenium::WebDriver::Proxy.new(:http => "IP:9091") #use the 9091 port we retrieved earlier
}

urlhub = "http://API_KEY:API_SECRET@hub.testingbot.com:4444/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120

@webdriver = Selenium::WebDriver.for :remote, :url => urlhub, :desired_capabilities => caps, :http_client => client
@webdriver.navigate.to "http://testingbot.com/"
puts @webdriver.title
@webdriver.quit
		

When the test has finished running, you can fetch the HAR file from your personal proxy:

curl http://IP:9090/proxy/9091/har

We have added a page in our support area with this browsermob proxy example.

Should you have any questions about this, please let us know in the comments or contact us.

VN:F [1.9.22_1171]
Rating: 6.0/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 2 votes)

Selenium Tunnel – Run Selenium tests on your staging environment.

selenium tunnel

Today we are proud to release our new Selenium Tunnel, which will enable you to run Selenium tests on your local computer and network infrastructure.
Whether you want to test on your local computer (localhost), on a staging server inside your LAN, or on a computer across VPN, our new Tunnel makes all of this possible in a secure and reliable way.

Our previous solution, a simple SSH remote port forwarding program, allowed for testing on a single local computer and was at times slow.
With the new Tunnel, we provide a more robust and faster solution. Here are a few of its features:

- Run tests on your local computer, on computers inside your LAN or across VPN.
- Fast: we cache static content on our end of the tunnel to reduce traffic inside the tunnel
- Secure: when you start the Tunnel, a pristine VM server is booted just for you.
- Robust: full HTTP(s) support, coded in Java
- Easy: very simple setup

Run tests on your local computer

When running Selenium tests you might want to test against your local staging environment.
Maybe you’ve updated some code or added a new feature and you want to make sure all regression tests still pass.

With the new Tunnel, you can easily test on http://localhost or http://10.0.1.5 without changing anything to your test code.
The only thing you need to do is point your tests to http://127.0.0.1 port 4445 instead of http://hub.testingbot.com port 4444.

The Tunnel is a Java based program (jar) which contains our very own secure HTTP(s) proxy, which will relay requests to our grid.
This way a browser on one of our instances can easily fetch webpages through the tunnel.

Fast

When booting the Tunnel, we boot up a fresh VM server just for you which is required to set up the tunnel.
Booting this VM takes 45 seconds max.

After your tests are finished the tunnel and VM server will be destroyed.

At our end of the tunnel, we added an accelerator called Squid, which is used by a lot of trusted companies.
Squid will keep a cache of the static content flowing through the tunnel and store it for the lifetime of the Tunnel.
When a test requests the same static content file multiple times it will never have to go through the tunnel as Squid will have it in its cache.
This optimisation will make sure your Tunnel stays fast.

Secure

All the requests to and from our servers will pass through the Tunnel, which is based on SSH.
The traffic flowing through your personal VM is only available to you.

When your tests are finished, the tunnel is destroyed together with everything on the VM server.

Robust

The Tunnel is built in Java with proven code and tests.
We support both HTTP and HTTPS usage inside the tunnel.

Starting the tunnel happens with a simple command on the command line and offers options like verbose logging and fast-fail regexes.

Easy

Setting up the Tunnel is very easy. Download the JAR file from our website and run it on your command line:

java -jar testingbot-tunnel.jar API_KEY API_SECRET

All you need to do is replace the API_KEY and API_SECRET with your own key and secret.
You should see “You may start your tests” when your Tunnel is ready.

To use your Tunnel, you need to modify the host and port inside your test file(s).
Instead of using our grid on http://hub.testingbot.com and port 4444, you now need to run your tests on http://localhost and port 4445.
This will make sure your commands flow through the secure Tunnel, reaching our Selenium grid.

If you have any questions or suggestions, please leave a comment or reach out to us via email.

Download our Selenium Tunnel.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)