There is not internet connection error when using BrowserMobProxyServer through Selenium

4,225 views
Skip to first unread message

Agustin Celentano

unread,
Jul 29, 2016, 2:57:47 PM7/29/16
to BrowserMob Proxy

Hello, 


I am trying to use BrowserMobProxyServer through Selenium (TESTNG). in a Mac in order to be able to change the User-Agent of a certain web page. First, When I run it to test it opening the google webpage, the chrome browser open but it says. "There is not internet connection" and nothing happens. Check attached screenshot. I believe I do not have any proxy to go out to internet. Same behaviour when using Firefox.

Do you know what I am doing wrong? Missing any step?


import org.apache.log4j.Logger;

import org.apache.log4j.xml.DOMConfigurator;

import org.openqa.selenium.Proxy;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.remote.CapabilityType;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.testng.annotations.AfterMethod;

import org.testng.annotations.BeforeMethod;

import org.testng.annotations.Test;

import net.lightbody.bmp.BrowserMobProxyServer;

import net.lightbody.bmp.client.ClientUtil;




public class TestLocalExchangePage 

{

public  WebDriver driver;

public static BrowserMobProxyServer server;


@BeforeMethod

    public void setUp() {

DOMConfigurator.configure("log4j.xml");

Logger log = Logger.getLogger("Tests");


server = new BrowserMobProxyServer();

server.start();

int port = server.getPort();

log.info(port);

Proxy proxy = ClientUtil.createSeleniumProxy(server);


DesiredCapabilities seleniumCapabilities = new DesiredCapabilities();

seleniumCapabilities.setCapability(CapabilityType.PROXY, proxy);

System.setProperty("webdriver.chrome.driver", "/Users/agustincelentano/Downloads/chromedriver");

driver = new ChromeDriver(seleniumCapabilities);

driver.get("https://www.google.com.ar");


}

@Test

public void testExchange() throws InterruptedException {

Logger log = Logger.getLogger("Tests");

log.info("Test things");

Thread.sleep(10000);

}



@AfterMethod

public void closeBrowser() {

driver.quit();

 

}

}


Thanks in advance


Agustin

Thereisnotconnection.png

je...@outlook.com

unread,
Jul 31, 2016, 3:21:03 PM7/31/16
to BrowserMob Proxy
If the browser can't connect to the proxy server, it will say "The proxy server is refusing connections". It looks like this is some other issue with your browser/computer/network configuration.

Agustin Celentano

unread,
Jul 31, 2016, 3:23:18 PM7/31/16
to browserm...@googlegroups.com
Hi, 

To solved my issue, I have to set the following lines: 

proxy.setHttpProxy("localhost:"+ server.getPort()); //The port generated by server.start();

proxy.setSslProxy("localhost:"+ server.getPort());

After thar, it worked. 



--

---
You received this message because you are subscribed to a topic in the Google Groups "BrowserMob Proxy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/browsermob-proxy/fALhlU0p0pI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to browsermob-pro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

CarrickD

unread,
Jun 9, 2017, 4:39:11 AM6/9/17
to BrowserMob Proxy
Hi Agustin,

Thank you so much for your post which has saved my day.  Just curiosity, how did you find out the solution? I spent 5 hours searching on the Internet, getting nothing. Thanks again.

CarrickD

在 2016年8月1日星期一 UTC+8上午3:23:18,Agustin Celentano写道:

杨鑫辉

unread,
Aug 21, 2017, 1:32:23 AM8/21/17
to BrowserMob Proxy
Thank you very very much! I have spent a lot of time finding answer for this problem, util i see this answer...You saved my day.


在 2016年8月1日星期一 UTC+8上午3:23:18,Agustin Celentano写道:
Hi, 

Gertjan Franken

unread,
Sep 15, 2017, 9:02:05 AM9/15/17
to BrowserMob Proxy
Thank you very much, this also worked for me! It's weird that all worked perfect on OS X Yosemite, but to achieve the same result on macOS Sierra I had to add those two lines of code.

Ruslan F

unread,
Dec 7, 2018, 7:20:44 PM12/7/18
to BrowserMob Proxy
Agustin, thank you!

Murali Vasudev

unread,
Jan 17, 2019, 8:50:32 AM1/17/19
to BrowserMob Proxy
Thank you so much. You saved my day. Its weird Mac OS updating has something thing to do with proxy setting.

Nili Davidor

unread,
Jan 12, 2020, 6:16:14 PM1/12/20
to BrowserMob Proxy
Thank you Agustin! 
To unsubscribe from this group and all its topics, send an email to browserm...@googlegroups.com.

Karthik Chess

unread,
Jul 7, 2020, 9:32:53 AM7/7/20
to BrowserMob Proxy
Hi Agustin

I am getting following error message after the change. Any idea how to resolve. this issue ?

"

Your connection is not private

Karthik Chess

unread,
Jul 7, 2020, 9:48:55 AM7/7/20
to browserm...@googlegroups.com

    The issue was fixed by adding following capabilities (DesiredCapabilities seleniumCapabilities = new DesiredCapabilities();)


        seleniumCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        seleniumCapabilities.setCapability (CapabilityType.ACCEPT_INSECURE_CERTS, true);


--

---
You received this message because you are subscribed to the Google Groups "BrowserMob Proxy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to browsermob-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/browsermob-proxy/b11e97ec-360d-4fbe-bc15-4c3ba6403dc6o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages