0

I try to use BrowserMob Proxy’s with WebDriver. I use the next code:

public static void main(String[] args) throws Exception {

        String strFilePath = "";

        // start the proxy
        ProxyServer server = new ProxyServer(4455);
        server.start();
        //captures the moouse movements and navigations
        server.setCaptureHeaders(true);
        server.setCaptureContent(true);

        // get the Selenium proxy object
        Proxy proxy = server.seleniumProxy();

        // configure it as a desired capability
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.PROXY, proxy);

        // start the browser up
        WebDriver driver = new FirefoxDriver(capabilities);

        // create a new HAR with the label "apple.com"
        server.newHar("assertselenium.com");

        // open yahoo.com
        driver.get("http://assertselenium.com");

        driver.get("http://assertselenium.com/2012/10/30/transformation-from-manual-tester-to-a-selenium-webdriver-automation-specialist/");

        // get the HAR data
        Har har = server.getHar();
        FileOutputStream fos = new FileOutputStream(strFilePath);
        har.writeTo(fos);
        server.stop();
        driver.quit();

    }

And I got the next error: The proxy server is refusing connections: Firefox is configured to use a proxy server that is refusing connections.

I try also to run the browsermob-proxy.bat with port 4455, and then I get the next error when I run the main:

java.net.BindException: Address already in use: JVM_Bind

How I can use BrowserMob Proxy’s?

Or Smith
  • 3,178
  • 12
  • 33
  • 60

3 Answers3

1

The code for stating the proxy seems to be correct. For the BindException, it should be obvious that something is already using the port 4455. You can check it (on Windows machine, written from memory):

netstat -ano | find "4455"

in Linux use lsof -i:4455 to get the PID and kill it. Anyway, for your proxy refusing connections, try setting the proxy explicitly, see if you have any luck, something like

proxy.setHttpProxy("localhost:4455");
proxy.setSslProxy("localhost:4455");

Also, make sure you are using up-to-date versions of FF and BMP.

Erki M.
  • 4,744
  • 1
  • 42
  • 67
0

java.net.BindException: Address already in use: JVM_Bind You get this error because on the mentioned port there is already one server running. May be you run your code again without stopping the server you started it at first instance.

Khushboo
  • 2,817
  • 2
  • 20
  • 21
0

Try disabling internet explorer proxy on your pc.

realheaven
  • 227
  • 1
  • 2
  • 8