client Package

class browsermobproxy.Client(url)

Initialises a new Client object

Parameters:url – This is where the BrowserMob Proxy lives
add_to_capabilities(capabilities)

Adds an ‘proxy’ entry to a desired capabilities dictionary with the BrowserMob proxy information

Parameters:capabilities – The Desired capabilities object from Selenium WebDriver
basic_authentication(domain, username, password)

This add automatic basic authentication

Parameters:
  • domain – domain to set authentication credentials for
  • username – valid username to use when authenticating
  • password – valid password to use when authenticating
blacklist(regexp, status_code)

Sets a list of URL patterns to blacklist

Parameters:
  • regex – a comma separated list of regular expressions
  • status_code – the HTTP status code to return for URLs that do not match the blacklist
clear_dns_cache()

Clears the DNS cache associated with the proxy instance

close()

shuts down the proxy and closes the port

har

Gets the HAR that has been recorded

headers(headers)

This sets the headers that will set by the proxy on all requests

Parameters:headers – this is a dictionary of the headers to be set
limits(options)

Limit the bandwidth through the proxy.

Parameters:options – A dictionary with all the details you want to set. downstreamKbps - Sets the downstream kbps upstreamKbps - Sets the upstream kbps latency - Add the given latency to each HTTP request
new_har(ref=None, options={})

This sets a new HAR to be recorded

Parameters:
  • ref – A reference for the HAR. Defaults to None
  • options – A dictionary that will be passed to BrowserMob Proxy with specific keywords. Keywords are: captureHeaders - Boolean, capture headers captureContent - Boolean, capture content bodies captureBinaryContent - Boolean, capture binary content
new_page(ref=None)

This sets a new page to be recorded

Parameters:ref – A reference for the new page. Defaults to None
remap_hosts(address, ip_address)

Remap the hosts for a specific URL

Parameters:
  • address – url that you wish to remap
  • ip_address – IP Address that will handle all traffic for the address passed in
request_interceptor(js)

Executes the javascript against each request

Parameters:js – the javascript to execute
response_interceptor(js)

Executes the javascript against each response

Parameters:js – the javascript to execute
retry(retry_count)

Retries. No idea what its used for, but its in the API...

Parameters:retry_count – the number of retries
rewrite_url(match, replace)

Rewrites the requested url.

Parameters:
  • match – a regex to match requests with
  • replace – unicode a string to replace the matches with
selenium_proxy()

Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy

timeouts(options)

Configure various timeouts in the proxy

Parameters:options – A dictionary with all the details you want to set. request - request timeout (in seconds) read - read timeout (in seconds) connection - connection timeout (in seconds) dns - dns lookup timeout (in seconds)
wait_for_traffic_to_stop(quiet_period, timeout)

Waits for the network to be quiet

Parameters:
  • quiet_period – number of seconds the network needs to be quiet for
  • timeout – max number of seconds to wait
webdriver_proxy()

Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy

whitelist(regexp, status_code)

Sets a list of URL patterns to whitelist

Parameters:
  • regex – a comma separated list of regular expressions
  • status_code – the HTTP status code to return for URLs that do not match the whitelist

Previous topic

Welcome to BrowserMob Proxy’s documentation!

Next topic

server Package

This Page