Getting started

It is fairly easy to get started using the tool. You would first instantiate the proxy service in your WebDriver driver class code, pass that proxy capability to your driver, and turn the capture mode on to retrieve the HTTP responses and requests being sent back and forth during the test as you drive the browser.

The following code sample to integrate with Selenium WebDriver is from the Neustar GitHub site:

// start the proxy
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start(0);

// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy); // configure it as a desired capability DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.PROXY, seleniumProxy); // start the browser up WebDriver driver = new FirefoxDriver(capabilities); // enable more detailed HAR capture proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT); // create a new HAR with the label "yahoo.com" proxy.newHar("yahoo.com"); // open yahoo.com driver.get("http://yahoo.com"); // get the HAR data Har har = proxy.getHar();
The online Wiki documentation to get up and running along with the source code is located at https://github.com/lightbody/browsermob-proxy#using-with-selenium.

BrowserMob Proxy also has the ability to test REST API requests and responses, allowing users to capture HTTP data without using the WebDriver. It has full SSL support via the man-in-the-middle (MITM) proxy using a secure certificate, Node.js bindings, logging, native, and custom DNS resolution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.39.74