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
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.
Hi,
To unsubscribe from this group and all its topics, send an email 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.