diff --git a/java/src/org/openqa/selenium/chromium/BUILD.bazel b/java/src/org/openqa/selenium/chromium/BUILD.bazel index 9b14784d4ec23..2b05e31f1f84b 100644 --- a/java/src/org/openqa/selenium/chromium/BUILD.bazel +++ b/java/src/org/openqa/selenium/chromium/BUILD.bazel @@ -1,5 +1,6 @@ load("//java:defs.bzl", "java_export") load("//java:version.bzl", "SE_VERSION") +load("//java:defs.bzl", "artifact", "java_export", "java_library") java_export( name = "chromium", @@ -19,5 +20,6 @@ java_export( "//java:auto-service", "//java/src/org/openqa/selenium/json", "//java/src/org/openqa/selenium/remote", + artifact("org.jspecify:jspecify:1.0.0"), ], ) diff --git a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java index 437d7063801d6..f467403ae3c46 100644 --- a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java +++ b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java @@ -20,6 +20,9 @@ import static org.openqa.selenium.remote.Browser.CHROME; import static org.openqa.selenium.remote.Browser.EDGE; import static org.openqa.selenium.remote.Browser.OPERA; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.net.URI; import java.net.URISyntaxException; @@ -67,6 +70,7 @@ * A {@link WebDriver} implementation that controls a Chromium browser running on the local machine. * It is used as the base class for Chromium-based browser drivers (Chrome, Edge). */ +@NullMarked public class ChromiumDriver extends RemoteWebDriver implements HasAuthentication, HasBiDi, @@ -90,8 +94,11 @@ public class ChromiumDriver extends RemoteWebDriver private final Optional devTools; private final Optional biDiUri; private final Optional biDi; - protected HasCasting casting; - protected HasCdp cdp; + /** May be null when the driver does not support casting; initialized during setup if available. */ + protected @Nullable HasCasting casting; + /** May be null when CDP is unavailable for the current browser/session. */ + protected @Nullable HasCdp cdp; + private final Map scriptKeys = new HashMap<>(); protected ChromiumDriver(