Search code examples
maven-3webdrivermanager-java

Webdrivermanager forceCache is trying to connect to URL


For my Selenium/Cucumber/Maven project I downloaded the latest version of the Chrome and IE driver via Webdrivermanager on an virtual machine with an internet connection. After this I used the same project (using the same Maven local repo folder) on a Windows server without an internet connection, set an override for the local Maven repo folder in IntelliJ and added the forceCache option:

ChromeDriverManager.getInstance().forceCache().setup();
driver = new ChromeDriver();

Version of webdrivermanager = 1.7.2

When executing a test via the command line of Windows with Maven command mvn test clean, I receive below connection error. The browser driver is available in the local repo.

INFO BrowserManager - Reading https://chromedriver.storage.googleapis.com/ 
to seek [chromedriver]

[main] INFO BrowserManager - Reading 
https://chromedriver.storage.googleapis.com/ to seek [chromedriver]
[main] WARN BrowserManager - [1/3] Exception reading 
https://chromedriver.storage.googleapis.com/ to seek [chromedriver]: 
org.apache.http.conn.HttpHostConnectException Connect to 
chromedriver.storage.googleapis.com:443 
[chromedriver.storage.googleapis.com/216.58.212.208] failed: Connection 
timed out: connect

UPDATE: I have executed my test again via the virtual machine with an internet connection. It looks like that Maven is still using the default .m2 folder, which doesn't contain the cached browser drivers and webdrivermanager tries to download the files. So this is not an webdrivermanager issue, but a Maven issue. Has anyone suggestions to fix this issue? I have already restarted my machine, but with no luck.


Solution

  • The cache used by WebDriverManager in a Windows machine is located at C:\Users\your-user\.m2\repository. Concretely, for chromedriver, the binary should be at C:\Users\your-user\.m2\repository\webdriver\chromedriver\win32\2.33\chromedriver.exe. Check this file actually exists, since this is what the forceCache() method is going to look for. I have doubled checked again and this feature is still working as expected. In your case, it seems that the cache file is not available, and therefore WebDriverManager tries to download it.