1

I am just trying to figure out if anyone else has seen their Selenium tests run significantly slower (takes 2+ minutes to start) when they load a profile into the FirefoxDriver as shown in: Selenium a default profile for the Firefox

The question originator of the above post mentioned this issue in a comment, but never updated whether he fixed this slowness issue.

At some point my tests stopped running all together and I started getting the error

org.openqa.selenium.WebDriverException: java.io.Exception: unexpected end of stream on Connection. 

If I remove the profile option from the FirefoxDriver call then the test runs within 5 seconds of selecting "RUN" but the test fails because the default profile Selenium uses does not have the certificates I need to access my site.

Anyone else in the same boat or know how to fix this? How do you adjust how much information is saved within a profile?

  • Firefox Version: 60.3.0
  • Selenium Version: 3.14.0
  • GeckoDriver Version: 0.23.0
  • OS: Linux Redhat 6
  • Eclipse Version: Neon

Code:

WebDriver browser;
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.get("SeleniumUser");
FirefoxOptions options = new FirefoxOptions().setProfile(ffprofile);
browser = new FirefoxDriver(options); // takes a long time and eventually fails here
browser.get("site.url");

If you take out the {options} parameter from the new FirefoxDriver() call the test will start in about 5 seconds. Keeping the options causes the error "org.openqa.selenium.WebDriverException: java.io.Exception: unexpected end of stream on Connection" as stated above.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
shagen
  • 11
  • 3

1 Answers1

2

When you initiate the process to load a new/existing FirefoxProfile through GeckoDriver the underlying framework consisting of:

  • The Driver (Selenium binding)
  • The Server (GeckoDriver)
  • The Client (Firefox Browser)

Needs to initialize and intercommunicate with different internal modules.

You can find a detailed discussion on how to access a FirefoxProfile through GeckoDriver with in Cannot resolve constructor FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)

Additionally the saved:

  • Bookmarks
  • Password
  • User Preferences

are also loaded when an existing FirefoxProfile loads. Hence some added time is required.

You can find a detailed discussion in webdriver.FirefoxProfile(): Is it possible to use a profile without making a copy of it?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352