Search code examples
javagoogle-chromeselenium-webdriverfirefoxgeckodriver

Disable Selenium Driver Manager


With Selenium 4.11.0, selenium officially enabled selenium driver manager, that checks if driver and browser are compatible.

This functionality may be arguably, but it is not part of my question. I would like to disable this behavior as my test environment is in closed network environment and with limited access to the internet. As from the documentation i did not found to which addresses an access needs to be provided, i would like to disable it.

The only known address to me is visible from the warning message: Apr 22, 2024 11:00:24 AM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1 WARNING: Exception trying to discover geckodriver version: error sending request for url (https://github.com/mozilla/geckodriver/releases/latest): error trying to connect: tcp connect error: Operation timed out (os error 110)

If anyone know how can i disable it please share with me, or if you can guide me to the list of all urls that can be addressed by selenium.


Solution

  • If you do not want SeleniumManager to manage your browser drivers, you can always download the required driver manually from internet, and set the driver location manually in you code. Selenium will automatically use the local driver and disables SeleniumManager

    See examples below:

    1. Below code will enable Selenium Manager:

      WebDriver driver = new FirefoxDriver();
      driver.manage().window().maximize();
      driver.get("https://google.com");
      driver.quit();
      
    2. Below code will use the driver specified in the code, thus disabling SeleniumManager:

      System.setProperty ("webdriver.gecko.driver", "C:/<full path>/geckodriver.exe");
      
      WebDriver driver = new FirefoxDriver();
      driver.manage().window().maximize();
      driver.get("https://google.com");
      driver.quit();
      

    On another note: Latest selenium expects setting driver location using Driver Service Class, off the top of my head can't recollect in which selenium version is the Service class introduced. But, I have checked for selenium v4.11.0, you can use System.setProperty to set driver path.