diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel b/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel index 8b2750d9a6ad0..fbf0948a2d6eb 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BUILD.bazel @@ -20,7 +20,6 @@ java_library( "//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 56cabb758f266..c858da3d5fc1a 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java @@ -24,9 +24,7 @@ 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; @@ -37,8 +35,6 @@ 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 { @@ -415,44 +411,10 @@ 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/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java b/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java index 6c78f8d7a7d21..11b758a56e469 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -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; @@ -243,18 +242,7 @@ void canLocateNodesInAGivenSandbox() { String sharedId = (String) ((RemoteValue) sharedIdMap.get("sharedId")).getValue().get(); assertThat(sharedId).isEqualTo(nodeId); - } - - @Test - 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() {