3

Selenium Webdriver 2.42.2, browsermob-proxy Beta 9, Windows 7/Firefox

I am trying to call the browsermob-proxy API to capture http network requests and after following this example. But, I get the following errors:

The proxy server is refusing connections

Firefox is configured to use a proxy server that is refusing connections.

Check the proxy settings to make sure that they are correct.
Contact your network administrator to make sure the proxy server is working.

Anyone know if this could be a network issue, we do not use proxy servers in our network. I have also run the browsermob-proxy.bat -port 9090 to startup the server. Below is a sample of the code I've tried:

public void setDriver(String browser,String environment,String platform) throws Exception {
ProxyServer server = null;

// start the proxy
server = new ProxyServer(9091);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);

// set the Selenium proxy object
Proxy proxy = server.seleniumProxy();
//Proxy proxy = new Proxy();
//proxy.setHttpProxy("localhost:9091");

caps = DesiredCapabilities.firefox();
caps.setCapability(CapabilityType.PROXY,proxy);

server.newHar("test");

public void closeDriver() throws Exception {
Har har = server.getHar(); // browserMob proxy

FileOutputStream fos = new FileOutputStream("C:/Downloads/browserMob.har");
har.writeTo(fos); // browserMob proxy
server.cleanup(); // browserMob proxy
server.stop(); // browserMob proxy

this.driver.quit();
tashuhka
  • 4,524
  • 3
  • 40
  • 62
carlc
  • 31
  • 1
  • 2

2 Answers2

1

There are 2 variants: 1) Browsermob Proxy Server didn't start; 2) Proxy Server started with wrong parametres;

If you have the second problem, try this code:

                server = new ProxyServer(9091);     
                server.setLocalHost(InetAddress.getByName("localhost"));
                server.start();
                server.setCaptureContent(true);
                server.setCaptureHeaders(true);
Maxim Kim
  • 141
  • 2
  • 8
0

As described above, but a couple of thoughts:

  1. Try using Firefox profile:
    As described in here: Webdriver and proxy server for firefox

  2. Try to add address parameter by: InetAddress.getLocalHost()

  3. Make sure port is open.

Community
  • 1
  • 1
Mikhail
  • 605
  • 4
  • 13