Home > Net >  Selenium WebDriverManager - Exception when running on Linux Server
Selenium WebDriverManager - Exception when running on Linux Server

Time:06-16

I am new to Selenium and having some issues.

I am using the WebDriverManager in connection with Selenium. This is my code:

WebDriverManager.chromedriver().setup();

When I run the code on my local system (Windows 10 OS), everything runs perfectly fine. When I run my code as a web application on our Linux Server (Ubuntu 18.04, Tomcat 9), I get the following exception:

io.github.bonigarcia.wdm.config.WebDriverManagerException: Exception reading resolution cache as a properties file
        at io.github.bonigarcia.wdm.cache.ResolutionCache.<init>(ResolutionCache.java:86)
        at io.github.bonigarcia.wdm.WebDriverManager.getResolutionCache(WebDriverManager.java:1490)
        at io.github.bonigarcia.wdm.WebDriverManager.clearResolutionCache(WebDriverManager.java:780)
        at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:1263)
        at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:1060)
        at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:393)
....
Caused by: java.io.IOException: No such file or directory
        at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.base/java.io.File.createNewFile(File.java:1035)
        at io.github.bonigarcia.wdm.cache.ResolutionCache.<init>(ResolutionCache.java:75)

I am using Selenium 4.2.1 and Webdriver 5.1.0.
On our Linux server, I have installed Google Chrome as described here. When running

google-chrome --version
-> Google Chrome 102.0.5005.115

I get the shown result, so I think Chrome should be installed correctly. Has anybody an idea?

CodePudding user response:

It seems it is failing to create the resolution cache, which is a properties files created by default in the following path: ~/.cache/selenium. You can try to create manually that path (although WebDriverManager should have been able to create when it does not exist).

In any case, to debug it properly, you need to check the WebDriverManager traces. For that, you need need to include a Logback configuration file (for example, like this) in your project classpath. The name of this file should be src/test/resources/logback-test.xml (if you want logs only for your tests) or src/test/resources/logback.xml (if you want logs for both tests and application code). Then, you can to use the following line to set the level to TRACE:

<logger name="io.github.bonigarcia" level="TRACE" />

For further info about logging with with SLF4J and Logback you can see the following tutorial.

  • Related