Skip to content

Commit 8b6a600

Browse files
committed
[cdp] Re-enable support for CDP for remote browsers
1 parent 63d9869 commit 8b6a600

5 files changed

Lines changed: 11 additions & 13 deletions

File tree

java/client/src/org/openqa/selenium/chromium/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ java_export(
1616
deps = [
1717
"//java:auto-service",
1818
"//java/client/src/org/openqa/selenium/devtools",
19-
"//java/client/src/org/openqa/selenium/devtools/noop",
2019
"//java/client/src/org/openqa/selenium/json",
2120
"//java/client/src/org/openqa/selenium/remote",
2221
artifact("com.google.guava:guava"),

java/client/src/org/openqa/selenium/devtools/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ java_export(
3434
"*.java",
3535
"events/*.java",
3636
"idealized/**/*.java",
37+
"noop/*.java",
3738
],
3839
exclude = PROTOTYPE_SOURCES + GENERATOR_SOURCES,
3940
),

java/client/src/org/openqa/selenium/devtools/DevToolsProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.google.auto.service.AutoService;
2121
import org.openqa.selenium.Capabilities;
22+
import org.openqa.selenium.devtools.noop.NoOpCdpInfo;
2223
import org.openqa.selenium.remote.AugmenterProvider;
2324
import org.openqa.selenium.remote.ExecuteMethod;
2425

@@ -41,7 +42,8 @@ public Class<HasDevTools> getDescribedInterface() {
4142

4243
@Override
4344
public HasDevTools getImplementation(Capabilities caps, ExecuteMethod executeMethod) {
44-
Optional<DevTools> devTools = SeleniumCdpConnection.create(caps).map(conn -> new DevTools(null, conn));
45+
CdpInfo info = new CdpVersionFinder().match(caps.getBrowserVersion()).orElseGet(NoOpCdpInfo::new);
46+
Optional<DevTools> devTools = SeleniumCdpConnection.create(caps).map(conn -> new DevTools(info::getDomains, conn));
4547

4648
return () -> devTools.orElseThrow(() -> new IllegalStateException("Unable to create connection to " + caps));
4749
}

java/client/src/org/openqa/selenium/devtools/noop/BUILD.bazel

Lines changed: 0 additions & 8 deletions
This file was deleted.

java/client/src/org/openqa/selenium/devtools/noop/NoOpDomains.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.openqa.selenium.devtools.noop;
1919

20+
import org.openqa.selenium.BuildInfo;
2021
import org.openqa.selenium.devtools.DevToolsException;
2122
import org.openqa.selenium.devtools.idealized.Domains;
2223
import org.openqa.selenium.devtools.idealized.Events;
@@ -27,13 +28,16 @@
2728

2829
public class NoOpDomains implements Domains {
2930

30-
private final static String WARNING =
31+
private static BuildInfo INFO = new BuildInfo();
32+
33+
private final static String WARNING = String.format(
3134
"You are using a no-op implementation of the CDP. The most likely reason" +
3235
" for this is that Selenium was unable to find an implementation of the " +
3336
"CDP protocol that matches your browser. Please be sure to include an " +
3437
"implementation on the classpath, possibly by adding a new (maven) " +
35-
"dependency of `org.seleniumhq.selenium:selenium-devtools:NN` where " +
36-
"`NN` matches the major version of the browser you're using.";
38+
"dependency of `org.seleniumhq.selenium:selenium-devtools-vNN:%s` where " +
39+
"`NN` matches the major version of the browser you're using.",
40+
INFO.getReleaseLabel());
3741

3842
@Override
3943
public Events<?> events() {

0 commit comments

Comments
 (0)