question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embedded mode with selenium doesn't load website

See original GitHub issue

When using embedded mode in a selenium test, websites will timeout and not load. I have tried on google, npr.org, yahoo.com, etc. I’ve tried a couple things to see if it makes a difference but no luck so far: setting setUseECC to true, setTrustAllServers to true. I’ve tried on 2 different machines and same results. Is there something I’m missing?

Java v8 selenium v3.3.1 bmp v2.1.4

Here is my test case:

// Create bmp proxy
		BrowserMobProxyServer proxy = new BrowserMobProxyServer();
		// proxy.start(0);
		try {
			proxy.start(9091, InetAddress.getLocalHost());
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		proxy.setHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
		proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
		proxy.setUseEcc(true);

		// Pass the proxy into desired capabilities
		Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
		DesiredCapabilities caps = new DesiredCapabilities();
		caps = DesiredCapabilities.chrome();
		caps.setCapability(CapabilityType.PROXY, seleniumProxy);

		// Turning off pop-up blocking
		ChromeOptions options = new ChromeOptions();
		options.addArguments("test-type");
		options.addArguments("disable-popup-blocking");
		caps.setCapability(ChromeOptions.CAPABILITY, options);

		// Create the browser session
		File file = new File(this.getClass().getResource(Constants.DRIVERS_PATH_LOCAL + "ChromeDriver.exe").getPath());
		System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
		WebDriver driver = new ChromeDriver(caps);

		// Create the har file

		proxy.newHar("SalesforceAddCandidate");

		// load website stuff
		
		driver.get("http://www.npr.org/");

		Har har = proxy.getHar();

		File harFile = new File("C:\\temp\\SalesforceAddCandidate");
		try {
			har.writeTo(harFile);
		} catch (IOException ex) {
			System.out.println(ex.toString());

		}
		proxy.stop();

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:29

github_iconTop GitHub Comments

2reactions
medigacommented, Dec 1, 2017

try this. hope that works

replace this

<dependency>
  <groupId>net.lightbody.bmp</groupId>
  <artifactId>browsermob-core</artifactId>
  <version>2.1.4</version>
  <scope>test</scope>
</dependency>

with

<dependency>
  <groupId>net.lightbody.bmp</groupId>
  <artifactId>browsermob-core</artifactId>
  <version>2.1.5</version>
</dependency>
1reaction
medigacommented, Jan 2, 2018

great news!! you definitely are not cursed 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some websites dont fully load/render in selenium headless ...
In this script, it doesn't load the login inputs when it accesses the discord API login page. As I can see in the...
Read more >
Selenium Focus Element Issues And How To Solve Them?
This is a comprehensive guide to help you understand some common Selenium focus element issues and how to solve these issues, with examples....
Read more >
Using https with Chrome in headless mode fails to load page
I have just starting testing with Chrome in headless mode. Works fine except in one case when I switch in the test run...
Read more >
Selenium: Attach to an Existing Chrome Browser with C# ...
Using the power of Chrome to verify existing browser sessions during testing with Selenium so that you can verify items on the page....
Read more >
How to modify HTTP request header in Selenium WebDriver ...
Now, I'm trying to use BrowserMob Proxy in Embedded mode, to achieve it, but something is not working. Proxy is running and ChromeDriver...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found