diff --git a/java/src/org/openqa/selenium/bidi/BiDi.java b/java/src/org/openqa/selenium/bidi/BiDi.java index 1275c45b19cfd..100b45404bb84 100644 --- a/java/src/org/openqa/selenium/bidi/BiDi.java +++ b/java/src/org/openqa/selenium/bidi/BiDi.java @@ -62,7 +62,7 @@ public void addListener(Event event, Consumer handler) { connection.addListener(event, handler); } - void addListener(String browsingContextId, Event event, Consumer handler) { + public void addListener(String browsingContextId, Event event, Consumer handler) { Require.nonNull("Event to listen for", event); Require.nonNull("Browsing context id", browsingContextId); Require.nonNull("Handler to call", handler); @@ -79,7 +79,7 @@ void addListener(String browsingContextId, Event event, Consumer handl connection.addListener(event, handler); } - void addListener(Set browsingContextIds, Event event, Consumer handler) { + public void addListener(Set browsingContextIds, Event event, Consumer handler) { Require.nonNull("List of browsing context ids", browsingContextIds); Require.nonNull("Event to listen for", event); Require.nonNull("Handler to call", handler); diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel b/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel new file mode 100644 index 0000000000000..8b2750d9a6ad0 --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel @@ -0,0 +1,27 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//java:defs.bzl", "java_library") + +java_library( + name = "browsingcontext", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/firefox:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/script", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote:api", + "//java/src/org/openqa/selenium/remote/http", + artifact("com.google.auto.service:auto-service-annotations"), + ], +) diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java index 7ba4d25656c84..e416b8f873cd3 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java @@ -24,7 +24,9 @@ import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.stream.Collectors; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.WindowType; import org.openqa.selenium.bidi.BiDi; import org.openqa.selenium.bidi.Command; @@ -35,6 +37,8 @@ import org.openqa.selenium.json.JsonInput; import org.openqa.selenium.json.TypeToken; import org.openqa.selenium.print.PrintOptions; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.remote.RemoteWebElement; public class BrowsingContext { @@ -42,6 +46,7 @@ public class BrowsingContext { private final String id; private final BiDi bidi; + private final WebDriver driver; private static final String CONTEXT = "context"; private static final String RELOAD = "browsingContext.reload"; private static final String HANDLE_USER_PROMPT = "browsingContext.handleUserPrompt"; @@ -83,6 +88,7 @@ public BrowsingContext(WebDriver driver, String id) { Require.precondition(!id.isEmpty(), "Browsing Context id cannot be empty"); + this.driver = driver; this.bidi = ((HasBiDi) driver).getBiDi(); this.id = id; } @@ -94,6 +100,7 @@ public BrowsingContext(WebDriver driver, WindowType type) { throw new IllegalArgumentException("WebDriver instance must support BiDi protocol"); } + this.driver = driver; this.bidi = ((HasBiDi) driver).getBiDi(); this.id = this.create(type); } @@ -108,6 +115,7 @@ public BrowsingContext(WebDriver driver, WindowType type, String referenceContex throw new IllegalArgumentException("WebDriver instance must support BiDi protocol"); } + this.driver = driver; this.bidi = ((HasBiDi) driver).getBiDi(); this.id = this.create(type, referenceContextId); } @@ -389,10 +397,44 @@ public RemoteValue locateNode(Locator locator) { return remoteValues.get(0); } + public WebElement locateElement(Locator locator) { + List remoteValues = + this.bidi.send( + new Command<>( + "browsingContext.locateNodes", + Map.of("context", id, "locator", locator.toMap(), "maxNodeCount", 1), + jsonInput -> { + Map result = jsonInput.read(Map.class); + try (StringReader reader = new StringReader(JSON.toJson(result.get("nodes"))); + JsonInput input = JSON.newInput(reader)) { + return input.read(new TypeToken>() {}.getType()); + } + })); + + List elements = nodeRemoteValueToWebElementConverter(remoteValues); + return elements.get(0); + } + public void close() { // This might need more clean up actions once the behavior is defined. // Specially when last tab or window is closed. // Refer: https://github.com/w3c/webdriver-bidi/issues/187 this.bidi.send(new Command<>("browsingContext.close", Map.of(CONTEXT, id))); } + + private List nodeRemoteValueToWebElementConverter(List remoteValues) { + return remoteValues.stream() + .map( + remoteValue -> { + WebElement element = new RemoteWebElement(); + ((RemoteWebElement) element).setParent(((RemoteWebDriver) this.driver)); + ((RemoteWebElement) element) + .setFileDetector(((RemoteWebDriver) this.driver).getFileDetector()); + remoteValue + .getSharedId() + .ifPresent(sharedId -> ((RemoteWebElement) element).setId(sharedId)); + return element; + }) + .collect(Collectors.toList()); + } } diff --git a/java/src/org/openqa/selenium/bidi/log/BUILD.bazel b/java/src/org/openqa/selenium/bidi/log/BUILD.bazel new file mode 100644 index 0000000000000..8060809df9202 --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/log/BUILD.bazel @@ -0,0 +1,22 @@ +load("//java:defs.bzl", "java_library") + +java_library( + name = "log", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote/http", + ], +) diff --git a/java/src/org/openqa/selenium/bidi/module/BUILD.bazel b/java/src/org/openqa/selenium/bidi/module/BUILD.bazel new file mode 100644 index 0000000000000..9706b1493f778 --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/module/BUILD.bazel @@ -0,0 +1,30 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//java:defs.bzl", "java_library") + +java_library( + name = "module", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/firefox:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", + "//java/src/org/openqa/selenium/bidi/storage", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote/http", + artifact("com.google.auto.service:auto-service-annotations"), + ], +) diff --git a/java/src/org/openqa/selenium/bidi/Browser.java b/java/src/org/openqa/selenium/bidi/module/Browser.java similarity index 93% rename from java/src/org/openqa/selenium/bidi/Browser.java rename to java/src/org/openqa/selenium/bidi/module/Browser.java index 6cbd326fc5155..c199eeab59716 100644 --- a/java/src/org/openqa/selenium/bidi/Browser.java +++ b/java/src/org/openqa/selenium/bidi/module/Browser.java @@ -15,13 +15,16 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Function; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Command; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.json.JsonInput; public class Browser { diff --git a/java/src/org/openqa/selenium/bidi/BrowsingContextInspector.java b/java/src/org/openqa/selenium/bidi/module/BrowsingContextInspector.java similarity index 97% rename from java/src/org/openqa/selenium/bidi/BrowsingContextInspector.java rename to java/src/org/openqa/selenium/bidi/module/BrowsingContextInspector.java index 08f4b9ddef2da..70bc5c9b5bddb 100644 --- a/java/src/org/openqa/selenium/bidi/BrowsingContextInspector.java +++ b/java/src/org/openqa/selenium/bidi/module/BrowsingContextInspector.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.io.StringReader; import java.util.Collections; @@ -25,6 +25,9 @@ import java.util.function.Consumer; import java.util.function.Function; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Event; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.browsingcontext.BrowsingContextInfo; import org.openqa.selenium.bidi.browsingcontext.NavigationInfo; import org.openqa.selenium.bidi.browsingcontext.UserPromptClosed; diff --git a/java/src/org/openqa/selenium/bidi/Input.java b/java/src/org/openqa/selenium/bidi/module/Input.java similarity index 95% rename from java/src/org/openqa/selenium/bidi/Input.java rename to java/src/org/openqa/selenium/bidi/module/Input.java index 45fc8d54871da..e8013c7383bf7 100644 --- a/java/src/org/openqa/selenium/bidi/Input.java +++ b/java/src/org/openqa/selenium/bidi/module/Input.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.lang.reflect.InvocationTargetException; import java.util.Collection; @@ -24,6 +24,9 @@ import java.util.stream.Collectors; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Command; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.interactions.Sequence; public class Input { diff --git a/java/src/org/openqa/selenium/bidi/LogInspector.java b/java/src/org/openqa/selenium/bidi/module/LogInspector.java similarity index 98% rename from java/src/org/openqa/selenium/bidi/LogInspector.java rename to java/src/org/openqa/selenium/bidi/module/LogInspector.java index 8c30a16a7a6e2..fde35d6b850ba 100644 --- a/java/src/org/openqa/selenium/bidi/LogInspector.java +++ b/java/src/org/openqa/selenium/bidi/module/LogInspector.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.util.Collections; import java.util.HashSet; @@ -23,6 +23,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.log.BaseLogEntry; import org.openqa.selenium.bidi.log.ConsoleLogEntry; import org.openqa.selenium.bidi.log.FilterBy; diff --git a/java/src/org/openqa/selenium/bidi/Network.java b/java/src/org/openqa/selenium/bidi/module/Network.java similarity index 96% rename from java/src/org/openqa/selenium/bidi/Network.java rename to java/src/org/openqa/selenium/bidi/module/Network.java index 880eaf5d68a5c..1f83ce1e2527a 100644 --- a/java/src/org/openqa/selenium/bidi/Network.java +++ b/java/src/org/openqa/selenium/bidi/module/Network.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.util.Collections; import java.util.HashSet; @@ -24,6 +24,10 @@ import java.util.function.Consumer; import org.openqa.selenium.UsernameAndPassword; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Command; +import org.openqa.selenium.bidi.Event; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.network.AddInterceptParameters; import org.openqa.selenium.bidi.network.BeforeRequestSent; import org.openqa.selenium.bidi.network.FetchError; diff --git a/java/src/org/openqa/selenium/bidi/Script.java b/java/src/org/openqa/selenium/bidi/module/Script.java similarity index 98% rename from java/src/org/openqa/selenium/bidi/Script.java rename to java/src/org/openqa/selenium/bidi/module/Script.java index e8d91031677f0..c93179fd56489 100644 --- a/java/src/org/openqa/selenium/bidi/Script.java +++ b/java/src/org/openqa/selenium/bidi/module/Script.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.io.Closeable; import java.io.StringReader; @@ -29,6 +29,10 @@ import java.util.function.Consumer; import java.util.function.Function; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Command; +import org.openqa.selenium.bidi.Event; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.script.ChannelValue; import org.openqa.selenium.bidi.script.EvaluateResult; import org.openqa.selenium.bidi.script.EvaluateResultExceptionValue; diff --git a/java/src/org/openqa/selenium/bidi/Storage.java b/java/src/org/openqa/selenium/bidi/module/Storage.java similarity index 94% rename from java/src/org/openqa/selenium/bidi/Storage.java rename to java/src/org/openqa/selenium/bidi/module/Storage.java index d2291960ac91a..e17711cdb8ff6 100644 --- a/java/src/org/openqa/selenium/bidi/Storage.java +++ b/java/src/org/openqa/selenium/bidi/module/Storage.java @@ -15,12 +15,15 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.bidi; +package org.openqa.selenium.bidi.module; import java.io.StringReader; import java.util.Map; import java.util.function.Function; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Command; +import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.storage.DeleteCookiesParameters; import org.openqa.selenium.bidi.storage.GetCookiesParameters; import org.openqa.selenium.bidi.storage.GetCookiesResult; diff --git a/java/src/org/openqa/selenium/bidi/network/BUILD.bazel b/java/src/org/openqa/selenium/bidi/network/BUILD.bazel new file mode 100644 index 0000000000000..f949510ca9c0a --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/network/BUILD.bazel @@ -0,0 +1,25 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//java:defs.bzl", "java_library") + +java_library( + name = "network", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/firefox:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote/http", + artifact("com.google.auto.service:auto-service-annotations"), + ], +) diff --git a/java/src/org/openqa/selenium/bidi/script/BUILD.bazel b/java/src/org/openqa/selenium/bidi/script/BUILD.bazel new file mode 100644 index 0000000000000..9fbd7d0bda4d1 --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/script/BUILD.bazel @@ -0,0 +1,25 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//java:defs.bzl", "java_library") + +java_library( + name = "script", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/firefox:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote/http", + artifact("com.google.auto.service:auto-service-annotations"), + ], +) diff --git a/java/src/org/openqa/selenium/bidi/storage/BUILD.bazel b/java/src/org/openqa/selenium/bidi/storage/BUILD.bazel new file mode 100644 index 0000000000000..d3befff87bb37 --- /dev/null +++ b/java/src/org/openqa/selenium/bidi/storage/BUILD.bazel @@ -0,0 +1,25 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("//java:defs.bzl", "java_library") + +java_library( + name = "storage", + srcs = glob( + [ + "*.java", + ], + ), + visibility = [ + "//java/src/org/openqa/selenium/bidi:__subpackages__", + "//java/src/org/openqa/selenium/firefox:__subpackages__", + "//java/src/org/openqa/selenium/remote:__pkg__", + "//java/test/org/openqa/selenium/bidi:__subpackages__", + "//java/test/org/openqa/selenium/grid:__subpackages__", + ], + deps = [ + "//java/src/org/openqa/selenium:core", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/json", + "//java/src/org/openqa/selenium/remote/http", + artifact("com.google.auto.service:auto-service-annotations"), + ], +) diff --git a/java/src/org/openqa/selenium/remote/BUILD.bazel b/java/src/org/openqa/selenium/remote/BUILD.bazel index bdc5239bfd7b7..984128c339eaa 100644 --- a/java/src/org/openqa/selenium/remote/BUILD.bazel +++ b/java/src/org/openqa/selenium/remote/BUILD.bazel @@ -43,6 +43,7 @@ java_library( ], visibility = [ "//java/src/org/openqa/selenium/bidi:__pkg__", + "//java/src/org/openqa/selenium/bidi/browsingcontext:__pkg__", "//java/src/org/openqa/selenium/devtools:__pkg__", ], exports = [ diff --git a/java/test/org/openqa/selenium/bidi/BUILD.bazel b/java/test/org/openqa/selenium/bidi/BUILD.bazel index f9d9f4eed1aa5..c48703c6838fe 100644 --- a/java/test/org/openqa/selenium/bidi/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/BUILD.bazel @@ -13,6 +13,11 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/security", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/BiDiTest.java b/java/test/org/openqa/selenium/bidi/BiDiTest.java index f997f2cbdec55..677d82a6eda6a 100644 --- a/java/test/org/openqa/selenium/bidi/BiDiTest.java +++ b/java/test/org/openqa/selenium/bidi/BiDiTest.java @@ -36,6 +36,7 @@ import org.openqa.selenium.bidi.browsingcontext.ReadinessState; import org.openqa.selenium.bidi.log.JavascriptLogEntry; import org.openqa.selenium.bidi.log.LogLevel; +import org.openqa.selenium.bidi.module.LogInspector; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; @@ -58,7 +59,7 @@ public void setUp() { @NotYetImplemented(EDGE) void canNavigateAndListenToErrors() throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { + try (org.openqa.selenium.bidi.module.LogInspector logInspector = new LogInspector(driver)) { CompletableFuture future = new CompletableFuture<>(); logInspector.onJavaScriptException(future::complete); diff --git a/java/test/org/openqa/selenium/bidi/browser/BUILD.bazel b/java/test/org/openqa/selenium/bidi/browser/BUILD.bazel index fcfc9fb62c973..1674c63133fa7 100644 --- a/java/test/org/openqa/selenium/bidi/browser/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/browser/BUILD.bazel @@ -13,6 +13,7 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/module", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/json", "//java/src/org/openqa/selenium/remote", diff --git a/java/test/org/openqa/selenium/bidi/browser/BrowserCommandsTest.java b/java/test/org/openqa/selenium/bidi/browser/BrowserCommandsTest.java index 70bf0a3bf13e4..8d557fbbe7964 100644 --- a/java/test/org/openqa/selenium/bidi/browser/BrowserCommandsTest.java +++ b/java/test/org/openqa/selenium/bidi/browser/BrowserCommandsTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.Browser; +import org.openqa.selenium.bidi.module.Browser; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel b/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel index f9d9f4eed1aa5..c48703c6838fe 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel @@ -13,6 +13,11 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/security", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInspectorTest.java b/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInspectorTest.java index 9f1e77b2cd5ce..f3210d836b72a 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInspectorTest.java +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInspectorTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.BrowsingContextInspector; +import org.openqa.selenium.bidi.module.BrowsingContextInspector; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java b/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java index 594e1ba49b49b..c3be8c5cc9260 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java @@ -31,7 +31,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.Script; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.bidi.script.EvaluateResult; import org.openqa.selenium.bidi.script.EvaluateResultSuccess; import org.openqa.selenium.bidi.script.LocalValue; @@ -344,6 +345,22 @@ void canLocateNodesInAGivenSandbox() { assertThat(sharedId).isEqualTo(nodeId); } + @Test + @NotYetImplemented(SAFARI) + @NotYetImplemented(IE) + @NotYetImplemented(CHROME) + @NotYetImplemented(EDGE) + @NotYetImplemented(FIREFOX) + void canFindElement() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + assertThat(browsingContext.getId()).isNotEmpty(); + + driver.get(pages.xhtmlTestPage); + + WebElement element = browsingContext.locateElement(Locator.css("p")); + assertThat(element.getText()).isEqualTo("Open new window"); + } + @AfterEach public void quitDriver() { if (driver != null) { diff --git a/java/test/org/openqa/selenium/bidi/input/BUILD.bazel b/java/test/org/openqa/selenium/bidi/input/BUILD.bazel index dea8d8abf20cf..33e1bdfd8451e 100644 --- a/java/test/org/openqa/selenium/bidi/input/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/input/BUILD.bazel @@ -15,6 +15,12 @@ java_selenium_test_suite( "selenium-remote", ], deps = [ + "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/chrome", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/input/CombinedInputActionsTest.java b/java/test/org/openqa/selenium/bidi/input/CombinedInputActionsTest.java index b7e9f2c439bd4..be18a31db19c9 100644 --- a/java/test/org/openqa/selenium/bidi/input/CombinedInputActionsTest.java +++ b/java/test/org/openqa/selenium/bidi/input/CombinedInputActionsTest.java @@ -45,8 +45,8 @@ import org.openqa.selenium.Point; import org.openqa.selenium.WaitingConditions; import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.Input; -import org.openqa.selenium.bidi.Script; +import org.openqa.selenium.bidi.module.Input; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.bidi.script.EvaluateResult; import org.openqa.selenium.bidi.script.EvaluateResultSuccess; import org.openqa.selenium.bidi.script.LocalValue; diff --git a/java/test/org/openqa/selenium/bidi/input/DefaultKeyboardTest.java b/java/test/org/openqa/selenium/bidi/input/DefaultKeyboardTest.java index 648af977be726..8f6e79c039151 100644 --- a/java/test/org/openqa/selenium/bidi/input/DefaultKeyboardTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DefaultKeyboardTest.java @@ -31,7 +31,7 @@ import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.Input; +import org.openqa.selenium.bidi.module.Input; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.Color; import org.openqa.selenium.support.Colors; diff --git a/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java b/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java index 3ba4f8688453e..e8e2664f76dcf 100644 --- a/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java @@ -43,8 +43,8 @@ import org.openqa.selenium.Point; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.Input; -import org.openqa.selenium.bidi.Script; +import org.openqa.selenium.bidi.module.Input; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.bidi.script.EvaluateResult; import org.openqa.selenium.bidi.script.EvaluateResultSuccess; import org.openqa.selenium.bidi.script.LocalValue; diff --git a/java/test/org/openqa/selenium/bidi/input/DefaultWheelTest.java b/java/test/org/openqa/selenium/bidi/input/DefaultWheelTest.java index 04d141b87f566..caca19874bdb5 100644 --- a/java/test/org/openqa/selenium/bidi/input/DefaultWheelTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DefaultWheelTest.java @@ -33,7 +33,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.bidi.BiDiException; -import org.openqa.selenium.bidi.Input; +import org.openqa.selenium.bidi.module.Input; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.WheelInput; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java b/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java index 5ccc7b119dd42..49ea5e185c759 100644 --- a/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java @@ -33,7 +33,7 @@ import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; import org.openqa.selenium.bidi.BiDiException; -import org.openqa.selenium.bidi.Input; +import org.openqa.selenium.bidi.module.Input; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.testing.Ignore; diff --git a/java/test/org/openqa/selenium/bidi/input/ReleaseCommandTest.java b/java/test/org/openqa/selenium/bidi/input/ReleaseCommandTest.java index c364486f5466b..0b4f76efa44b2 100644 --- a/java/test/org/openqa/selenium/bidi/input/ReleaseCommandTest.java +++ b/java/test/org/openqa/selenium/bidi/input/ReleaseCommandTest.java @@ -29,7 +29,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.Input; +import org.openqa.selenium.bidi.module.Input; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.interactions.Actions; diff --git a/java/test/org/openqa/selenium/bidi/log/BUILD.bazel b/java/test/org/openqa/selenium/bidi/log/BUILD.bazel index f9d9f4eed1aa5..c48703c6838fe 100644 --- a/java/test/org/openqa/selenium/bidi/log/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/log/BUILD.bazel @@ -13,6 +13,11 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/security", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/log/LogInspectorTest.java b/java/test/org/openqa/selenium/bidi/log/LogInspectorTest.java index 792cfd602d4c7..fc6e4f565d4f8 100644 --- a/java/test/org/openqa/selenium/bidi/log/LogInspectorTest.java +++ b/java/test/org/openqa/selenium/bidi/log/LogInspectorTest.java @@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.LogInspector; +import org.openqa.selenium.bidi.module.LogInspector; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/network/AddInterceptParametersTest.java b/java/test/org/openqa/selenium/bidi/network/AddInterceptParametersTest.java index 9174699d84d90..059764af42d84 100644 --- a/java/test/org/openqa/selenium/bidi/network/AddInterceptParametersTest.java +++ b/java/test/org/openqa/selenium/bidi/network/AddInterceptParametersTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.Network; +import org.openqa.selenium.bidi.module.Network; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/network/BUILD.bazel b/java/test/org/openqa/selenium/bidi/network/BUILD.bazel index 233de4b2cd52d..c8fedb2afd95b 100644 --- a/java/test/org/openqa/selenium/bidi/network/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/network/BUILD.bazel @@ -13,6 +13,11 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/security", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java b/java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java index 681b2b1c4fd79..3cf32dade7b4c 100644 --- a/java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java +++ b/java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java @@ -35,7 +35,7 @@ import org.openqa.selenium.TimeoutException; import org.openqa.selenium.UsernameAndPassword; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.bidi.Network; +import org.openqa.selenium.bidi.module.Network; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.support.ui.ExpectedConditions; diff --git a/java/test/org/openqa/selenium/bidi/network/NetworkEventsTest.java b/java/test/org/openqa/selenium/bidi/network/NetworkEventsTest.java index b976eb0d93e57..3076ca532b119 100644 --- a/java/test/org/openqa/selenium/bidi/network/NetworkEventsTest.java +++ b/java/test/org/openqa/selenium/bidi/network/NetworkEventsTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; import org.openqa.selenium.Cookie; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.bidi.Network; +import org.openqa.selenium.bidi.module.Network; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/script/BUILD.bazel b/java/test/org/openqa/selenium/bidi/script/BUILD.bazel index f9d9f4eed1aa5..c48703c6838fe 100644 --- a/java/test/org/openqa/selenium/bidi/script/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/script/BUILD.bazel @@ -13,6 +13,11 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/script", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/security", "//java/src/org/openqa/selenium/json", diff --git a/java/test/org/openqa/selenium/bidi/script/LocalValueTest.java b/java/test/org/openqa/selenium/bidi/script/LocalValueTest.java index 7aaea8089c488..e20e1e4b07b36 100644 --- a/java/test/org/openqa/selenium/bidi/script/LocalValueTest.java +++ b/java/test/org/openqa/selenium/bidi/script/LocalValueTest.java @@ -32,7 +32,7 @@ import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.Script; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.testing.JupiterTestBase; import org.openqa.selenium.testing.NotYetImplemented; diff --git a/java/test/org/openqa/selenium/bidi/script/ScriptCommandsTest.java b/java/test/org/openqa/selenium/bidi/script/ScriptCommandsTest.java index 0d044d077f945..18f7e0b47bfd5 100644 --- a/java/test/org/openqa/selenium/bidi/script/ScriptCommandsTest.java +++ b/java/test/org/openqa/selenium/bidi/script/ScriptCommandsTest.java @@ -41,10 +41,10 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.LogInspector; -import org.openqa.selenium.bidi.Script; import org.openqa.selenium.bidi.log.ConsoleLogEntry; import org.openqa.selenium.bidi.log.LogLevel; +import org.openqa.selenium.bidi.module.LogInspector; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/script/ScriptEventsTest.java b/java/test/org/openqa/selenium/bidi/script/ScriptEventsTest.java index 604ae3f821f4f..13f10c7e5ecdb 100644 --- a/java/test/org/openqa/selenium/bidi/script/ScriptEventsTest.java +++ b/java/test/org/openqa/selenium/bidi/script/ScriptEventsTest.java @@ -33,8 +33,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.Script; import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.module.Script; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.testing.JupiterTestBase; diff --git a/java/test/org/openqa/selenium/bidi/storage/BUILD.bazel b/java/test/org/openqa/selenium/bidi/storage/BUILD.bazel index c0db6bf565e6f..02a018235e42d 100644 --- a/java/test/org/openqa/selenium/bidi/storage/BUILD.bazel +++ b/java/test/org/openqa/selenium/bidi/storage/BUILD.bazel @@ -13,6 +13,9 @@ java_selenium_test_suite( ], deps = [ "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/module", + "//java/src/org/openqa/selenium/bidi/network", + "//java/src/org/openqa/selenium/bidi/storage", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/json", "//java/src/org/openqa/selenium/remote", diff --git a/java/test/org/openqa/selenium/bidi/storage/StorageCommandsTest.java b/java/test/org/openqa/selenium/bidi/storage/StorageCommandsTest.java index 47d201a40125b..4d5f6d5106a99 100644 --- a/java/test/org/openqa/selenium/bidi/storage/StorageCommandsTest.java +++ b/java/test/org/openqa/selenium/bidi/storage/StorageCommandsTest.java @@ -34,7 +34,7 @@ import org.openqa.selenium.Cookie; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.Storage; +import org.openqa.selenium.bidi.module.Storage; import org.openqa.selenium.bidi.network.BytesValue; import org.openqa.selenium.testing.JupiterTestBase; import org.openqa.selenium.testing.NotYetImplemented; diff --git a/java/test/org/openqa/selenium/grid/router/BUILD.bazel b/java/test/org/openqa/selenium/grid/router/BUILD.bazel index 6b531cf7b3e1e..9766de9de45ff 100644 --- a/java/test/org/openqa/selenium/grid/router/BUILD.bazel +++ b/java/test/org/openqa/selenium/grid/router/BUILD.bazel @@ -83,6 +83,10 @@ java_selenium_test_suite( browsers = ["firefox"], deps = [ ":support", + "//java/src/org/openqa/selenium/bidi", + "//java/src/org/openqa/selenium/bidi/browsingcontext", + "//java/src/org/openqa/selenium/bidi/log", + "//java/src/org/openqa/selenium/bidi/module", "//java/src/org/openqa/selenium/firefox", "//java/src/org/openqa/selenium/grid/config", "//java/src/org/openqa/selenium/remote", diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java index 5c50ae68dc193..a9544b0723313 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java @@ -33,11 +33,11 @@ import org.openqa.selenium.bidi.BiDiSessionStatus; import org.openqa.selenium.bidi.Command; import org.openqa.selenium.bidi.HasBiDi; -import org.openqa.selenium.bidi.LogInspector; import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; import org.openqa.selenium.bidi.browsingcontext.NavigationResult; import org.openqa.selenium.bidi.log.ConsoleLogEntry; import org.openqa.selenium.bidi.log.LogLevel; +import org.openqa.selenium.bidi.module.LogInspector; import org.openqa.selenium.environment.webserver.AppServer; import org.openqa.selenium.environment.webserver.NettyAppServer; import org.openqa.selenium.firefox.FirefoxOptions;