How to initialize firefox with a Selenium Java project using Java 20

271 Views Asked by At

Which version of geckodriver should I use for Java version 20 and selenium v4.10.0 ? while my firefox is 114. when I use geckodriver 0.33.0 I get this error:

Exception in thread "main" org.openqa.selenium.remote.NoSuchDriverException: geckodriver located at path, but invalid
1

There are 1 best solutions below

0
On

Initializing Firefox with GeckoDriver

Using Selenium v4.10.0, GeckoDriver v0.33.0 and v114.0.1 you can use the minimum code block:

WebDriver driver = new FirefoxDriver();
driver.get("https://www.selenium.dev/");

Console Output:

Jun 11, 2023 3:58:24 AM org.openqa.selenium.remote.service.DriverService$Builder getLogOutput
INFO: Driver logs no longer sent to console by default; https://www.selenium.dev/documentation/webdriver/drivers/service/#setting-log-output