Interface Test-browsermob-proxy

Source: Internet
Author: User

Interface Test-browsermob-proxy

Provides the command line method or is embedded into the Java project to generate the HAR file plug-in through api, which is a sub-project of selenium. The specific process is a bit similar to fenders der or Charles. How to enable a port to monitor all HTTP requests under a port for data capture.
Java API dependency
 
compile 'net.lightbody.bmp:browsermob-core-littleproxy:2.1.0-beta-4' compile 'org.seleniumhq.selenium:selenium-java:2.49.0'
Code
 
BrowserMobProxy proxy = new BrowserMobProxyServer(); proxy.start(); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.PROXY, seleniumProxy); WebDriver driver = new FirefoxDriver(capabilities); proxy.newHar("http://www.baidu.com"); driver.get("http://www.baidu.com"); Har har = proxy.getHar(); har.writeTo(new File("baidu.com.har")); driver.close(); 

The running process is as follows:

Command Line

Download the release version, decompress it, go to the bin directory, and execute the command

sh browsermob-proxy
Output the following information:
 
58deMacBook-Pro-7:bin wuxian$ sh browsermob-proxy Running BrowserMob Proxy using LittleProxy implementation. To revert to the legacy implementation, run the proxy with the command-line option '--use-littleproxy false'. [INFO 2016-01-14T19:23:50,254 net.lightbody.bmp.proxy.Main] (main) Starting BrowserMob Proxy version 2.1.0-beta-4 [INFO 2016-01-14T19:23:51,510 org.eclipse.jetty.util.log] (main) jetty-7.x.y-SNAPSHOT [INFO 2016-01-14T19:23:51,546 org.eclipse.jetty.util.log] (main) started o.e.j.s.ServletContextHandler{/,null} [INFO 2016-01-14T19:23:52,463 org.eclipse.jetty.util.log] (main) Started SelectChannelConnector@auto.58corp.com:8080


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.