When I create a .jar
file and want to start the firefox webdriver
I get an Error. It works if I run it in VS-Code
.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.openqa.selenium.WebDriverException: Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'DESKTOP', ip: 'IP', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: driver.version: FirefoxDriver
at java.base/java.util.Optional.orElseThrow(Optional.java:403)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:230)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:164)
at hegahelperjava.Test.main(Test.java:13)
I already added SLF4j to my maven dependecies like they said here: java - SLF4J
Here a snippet to recreate the problem:
//selenium
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
//webdrivermanager
import io.github.bonigarcia.wdm.WebDriverManager;
public class Test {
public static void main(String[] args) {
String driversPath = "PATHTODRIVER";
WebDriverManager.firefoxdriver().cachePath(driversPath).avoidOutputTree().setup();
FirefoxOptions options = new FirefoxOptions();
WebDriver driver = new FirefoxDriver(options);
}
}
CodePudding user response:
To make a conclusion.
If something does not work, try to update your dependencies
fixes most problems
In This Case selenium 4.1.0
did not allow to execute firefoxdriver
when the app is packed into a jar. It works fine with selenium 4.1.4
.