BrowserMob Proxy
We offer support for the BrowserMob proxy version 2.12 (updated August 16, 2016), which allows you to manipulate HTTP traffic during your Selenium tests.
By using this proxy, you can:- Set/Get HTTP Headers during your tests.
- Capture performance data with HAR files.
- Simulate network traffic and latency.
- Rewrite HTTP requests and responses.
We provide a private and secure proxy, which works together with our grid and only you can access.
To get started, please follow the example below.
Starting the proxy
The first time you initiate this request, we boot up a pristine virtual machine for you, which only you can access.
The response of this call will have a PENDING state, which means a server is being started for you.
The state should soon be READY. In the response you will find your personal server IP.
You can now use this personal IP (109.68.162.170 in this example) as your BrowserMob proxy. The port will always be 9090.
Using the proxy
Please see the README file on GitHub for all of the BrowserMob proxy's commands.
An example where we will collect performance data in a HAR file, together with a Selenium test run by Ruby would be:
In the response you will receive a port which you can use as proxy.
For this example, we will assume the returned port is 9091.
#!/usr/bin/env ruby
require "rubygems"
require 'testingbot'
gem "selenium-webdriver"
require "selenium-webdriver"
caps = {
:browserName => "firefox",
:version => "latest",
:platform => "WINDOWS",
:proxy => Selenium::WebDriver::Proxy.new(:http => "109.68.162.170:9091") #use the 9091 port and personal ip we retrieved earlier
}
urlhub = "https://API_KEY:API_SECRET@hub.testingbot.com/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 "https://testingbot.com/"
puts @webdriver.title
@webdriver.quit
Use BrowserMob with our Tunnel
The good thing about the Browsermob proxy is that you can specify an upstream proxy, meaning we can use the Browsermob proxy in our tests and set its upstream proxy to our Tunnel.
So to start this process, here's what should happen: