Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with BrowserMob Proxy


Patrick Lightbody, one of the core originators of Selenium and the creator of Selenium RC with Paul Hammant, created the BrowserMob proxy while working on his start-up, BrowserMob. BrowserMob Proxy allows you to control the way traffic is filtered to the browser.

We can also change the headers that are supplied to the server. This allows us to do a number of things.

Creating and starting a proxy

When working with BrowserMob Proxy, we will need to make sure that we start the proxy so that we can use the API and change what we need.

We will need to start the proxy and make sure that we can then interact with it:

  1. Create a new Project in IntelliJ.

  2. Add the BrowserMob JAR files to the project so that we can use it:

    ProxyServer proxy = New ProxyServer(9876);
    proxy.start();
  3. When we want to stop the server, we just call the following method:

    proxy.stop()

We successfully started the server by passing in the port. The server needs to be started before we can do any of the different...