Selenium firefox webdriver failed to update gecko (tcp connect error)

32 Views Asked by At

I'm adding Selenium tests in a dedicated project to test a web application. The project uses java 17 and it has the following dependency

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.18.1</version>
    <scope>compile</scope>
</dependency>

I installed the last version of Mozilla Firefox on my computer (124.0 as of 20/03/24). I wrote a bunch of tests in java and it's working as expected... but my problem is that each and every new instance of FirefoxDriver is trying to update gecko driver before starting the test. It is waiting for the timeout before starting the test which slow down every test by 30secs... Error in console is :

2024-03-20T14:17:46.115+01:00 WARN 25024 --- [ main] o.o.selenium.manager.SeleniumManager : Exception managing firefox: error sending request for url (https://github.com/mozilla/geckodriver/releases/latest): error trying to connect: tcp connect error: Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu. (os error 10060)

I'm behind an enterprise proxy. If I run the tests without VPN, I don't face this timeout but I can't access the webapplication I'm testing. I guess it's a proxy issue but once MF is started after the gecko timeout, I can access anything on the MF instance (https github, google, my internal webapp...) so I don't understand what is wrong in the configuration.

I'm creating a new instance of FirefoxDriver with the following code, java comments are my tries to solve the problem without success :

        final FirefoxOptions opts = new FirefoxOptions();
        if (BooleanUtils.isTrue(this.browserIsHeadless)) {
            opts.addArguments("--headless");
        }
//        opts.addPreference("network.proxy.type", 4);
//        opts.addPreference("app.update.auto", false);
//        opts.addPreference("app.update.enabled", false);
//        opts.addPreference("browser.helperApps.alwaysAsk.force", false);
//        opts.addPreference("browser.download.folderList", 2);
//        opts.addPreference("browser.download.manager.showWhenStarting", false);
//        opts.addPreference("browser.download.panel.shown", false);
//        opts.addPreference("extensions.blocklist.enabled", false);
//        opts.addPreference("browser.download.manager.alertOnEXEOpen", false);
//        opts.addPreference("browser.download.manager.focusWhenStarting", false);
//        opts.addPreference("browser.download.manager.useWindow", true);
//        opts.addPreference("browser.download.manager.closeWhenDone", true);
//        opts.addPreference("media.gmp-manager.cert.requireBuiltIn", false);
//        opts.addPreference("media.gmp-manager.cert.checkAttributes", false);
//        opts.addPreference("media.gmp-provider.enabled", false);
//        opts.addPreference("media.gmp-widevinecdm.enabled", false);
//        opts.addPreference("media.gmp-widevinecdm.visible", false);
//        opts.addPreference("media.gmp.trial-create.enabled", false);
//        final Proxy proxy = new Proxy();
//        proxy.setAutodetect(true);
//        opts.addPreference("network.proxy.type", 4);
//        opts.setCapability("proxy", proxy);

        this.setDriver(new FirefoxDriver(opts));

I can accept any solution that allows me to run my tests without waiting 30s for gecko update timeout, such that :

  • Disable gecko update (I do have a local gecko in my windows path)
  • Bypass proxy to check update
  • Configure proxy of FirefoxDriver in an other way
  • If no real solution is found, reduce the timeout to 1 second
1

There are 1 best solutions below

0
Vincent Passau On

Slept on it and I found the solution this morning. I had to configure the enterprise proxy to access github and I had to avoid proxy to access the webapp I'm testing.

 final Proxy proxy = new Proxy();
 proxy.setHttpProxy("host:port");
 proxy.setSslProxy("host:port");
 proxy.setNoProxy("*.company.com,*localhost");
 opts.setCapability("proxy", proxy);
 this.setDriver(new FirefoxDriver(opts));