1

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);
    }
}
Muddyblack k
  • 314
  • 3
  • 16
  • 1
    Try adding the NOOP jar to your libs. You can get it here: https://repo1.maven.org/maven2/org/slf4j/slf4j-nop/1.7.9/ – pcalkins May 02 '22 at 17:39
  • 1
    changed nothing – Muddyblack k May 02 '22 at 17:49
  • 2
    yeah, I wouldn't think the noop warning would cause it to not run... I would check into webdrivermanager's output. You're setting the cachePath to something, so maybe check permissions and that sort of thing. ( if (!driver.canExecute()) { ... thisDriver.setExecutable (true, true); } Your exception doesn't list the driver version which seems unusual. Maybe also switch to using latest version 4 Selenium and Java 8. – pcalkins May 02 '22 at 18:33
  • 1
    Oh xD yeah Selenium 4.1.4 does work out – Muddyblack k May 02 '22 at 19:29

1 Answers1

0

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.

Muddyblack k
  • 314
  • 3
  • 16