Features
< Back to Blog Overview

BrowserMob Proxy Tutorial

2012-05-17
TestingBot and BrowserMob Proxy
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews

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.

TestingBot Logo

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.

Other Articles

blank

Today we have added full support for Webdriver-backed Selenium, which allows you to use the two API's together in a single test. By using this f...

Read more
Test TV - Live video stream of your tests running in the Cloud

Today we released a new feature in our TestingBot member area called Test TV.

Read more
Selenium Tunnel - Run Selenium tests on your staging environment.

Today we are proud to release our new Selenium Tunnel, which will enable you to run Selenium tests on your local computer and network infrastruct...

Read more
iPhone and iPad Selenium Testing with Webdriver

Since our last post announcing Mac OS X Selenium support, we now have added iPhone and iPad to the mix.

Read more
Mac OS X Selenium testing. Webdriver and Selenium RC testing with Apple.

We will make a lot of people happy with this announcement: today we start providing our customers with Mac OS X testing on-demand. Next to testin...

Read more
Samsung Galaxy Tab Testing with Selenium Webdriver

We are pleased to announce that we have added Samsung Galaxy Tab testing to our Selenium grid.

Read more