TestingBot Blog

TestingBot provides a cloud of browsers to run Automated, Live and Visual browser testing.

< Back to Blog Overview

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

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.

< Back to Blog Overview

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required