What happened?
Up to and including Selenium 4.10.0 it was possible to create a ChromeDriverService where the Selenium Manager automatically downloads the ChromeDriver (Chrome is already installed).
DriverService driverService = new ChromeDriverService.Builder().usingAnyFreePort().build();
driverService.start();
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(driverService.getUrl(), new ChromeOptions());
remoteWebDriver.navigate().to("https://www.selenium.dev");
Since Selenium 4.11.0 this code fails showing the following stacktrace:
Exception in thread "main" java.lang.NullPointerException
at java.base/java.io.File.<init>(File.java:278)
at org.openqa.selenium.os.ExecutableFinder.find(ExecutableFinder.java:47)
at org.openqa.selenium.os.OsProcess.<init>(OsProcess.java:63)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:35)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:198)
at org.example.Main.main(Main.java:24))
Looking at the ChromeDriverService documentation i tried using ChromeDriverService.createDefaultService().
DriverService driverService = ChromeDriverService.createDefaultService();
driverService.start();
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(driverService.getUrl(), new ChromeOptions());
remoteWebDriver.navigate().to("https://www.selenium.dev");
This yields the same result:
Exception in thread "main" java.lang.NullPointerException
at java.base/java.io.File.<init>(File.java:278)
at org.openqa.selenium.os.ExecutableFinder.find(ExecutableFinder.java:47)
at org.openqa.selenium.os.OsProcess.<init>(OsProcess.java:63)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:35)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:198)
at org.example.Main.main(Main.java:24)
The documentation of ChromeDriverService.createDefaultService() states that
In this configuration, the service will use the ChromeDriver executable identified by DriverFinder.getPath(DriverService, Capabilities).
But looking into the ChromeDriverServices and DriverServices builder code i could not find any usage of DriverFinder.getPath().
The only working solution i came up with is
SeleniumManagerOutput.Result result = SeleniumManager.getInstance().getDriverPath(new ChromeOptions(), false);
DriverService driverService = new ChromeDriverService.Builder()
.usingDriverExecutable(newFile(result.getDriverPath()))
.usingAnyFreePort()
.build();
driverService.start();
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(driverService.getUrl(), new ChromeOptions());
remoteWebDriver.navigate().to("https://www.selenium.dev");
From my point of view, contrary to the documentation, the use of DriverFinder.getPath() is missing when using the ChromeDriverService.Builder with default values.
How can we reproduce the issue?
public class Main {
public static void main(String[] args) throws IOException {
// Use either Builder() or createDefaultService()
// DriverService driverService = new ChromeDriverService.Builder().usingAnyFreePort().build();
DriverService driverService = ChromeDriverService.createDefaultService();
driverService.start(); // will fail using Selenium 4.11.0 and later
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(driverService.getUrl(), new ChromeOptions());
remoteWebDriver.navigate().to("https://www.selenium.dev");
}
}
Relevant log output
Sept. 04, 2023 3:53:29 PM org.openqa.selenium.remote.service.DriverService start
FINE: Starting driver at null with [--port=44284]
Exception in thread "main" java.lang.NullPointerException
at java.base/java.io.File.<init>(File.java:278)
at org.openqa.selenium.os.ExecutableFinder.find(ExecutableFinder.java:47)
at org.openqa.selenium.os.OsProcess.<init>(OsProcess.java:63)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:35)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:198)
at org.example.Main.main(Main.java:33)
Operating System
Windows 10
Selenium version
4.12.0 [Java]
What are the browser(s) and version(s) where you see this issue?
Chrome 116.0.5845.141
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 116.0.5845.96
Are you using Selenium Grid?
No Selenium Grid involved
What happened?
Up to and including Selenium 4.10.0 it was possible to create a ChromeDriverService where the Selenium Manager automatically downloads the ChromeDriver (Chrome is already installed).
Since Selenium 4.11.0 this code fails showing the following stacktrace:
Looking at the ChromeDriverService documentation i tried using
ChromeDriverService.createDefaultService().This yields the same result:
The documentation of
ChromeDriverService.createDefaultService()states thatBut looking into the ChromeDriverServices and DriverServices builder code i could not find any usage of
DriverFinder.getPath().The only working solution i came up with is
From my point of view, contrary to the documentation, the use of
DriverFinder.getPath()is missing when using the ChromeDriverService.Builder with default values.How can we reproduce the issue?
public class Main { public static void main(String[] args) throws IOException { // Use either Builder() or createDefaultService() // DriverService driverService = new ChromeDriverService.Builder().usingAnyFreePort().build(); DriverService driverService = ChromeDriverService.createDefaultService(); driverService.start(); // will fail using Selenium 4.11.0 and later RemoteWebDriver remoteWebDriver = new RemoteWebDriver(driverService.getUrl(), new ChromeOptions()); remoteWebDriver.navigate().to("https://www.selenium.dev"); } }Relevant log output
Operating System
Windows 10
Selenium version
4.12.0 [Java]
What are the browser(s) and version(s) where you see this issue?
Chrome 116.0.5845.141
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 116.0.5845.96
Are you using Selenium Grid?
No Selenium Grid involved