diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java index c3969e2275017..bc8b33a6e068b 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java @@ -160,29 +160,36 @@ public List getTopLevelContexts() { new Command<>("browsingContext.getTree", new HashMap<>(), browsingContextInfoListMapper)); } - // Yet to be implemented by browser vendors - private void reload() { - this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id))); + public NavigationResult reload() { + return this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id), navigationInfoMapper)); } // Yet to be implemented by browser vendors - private void reload(boolean ignoreCache) { - this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id, "ignoreCache", ignoreCache))); + private NavigationResult reload(boolean ignoreCache) { + return this.bidi.send(new Command<>( + RELOAD, + ImmutableMap.of(CONTEXT, id, "ignoreCache", ignoreCache), + navigationInfoMapper)); } - // Yet to be implemented by browser vendors - private void reload(ReadinessState readinessState) { - this.bidi.send( - new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id, "wait", readinessState.toString()))); + // TODO: Handle timeouts in case of Readiness state "interactive" and "complete". + // Refer https://github.com/w3c/webdriver-bidi/issues/188 + public NavigationResult reload(ReadinessState readinessState) { + return this.bidi.send( + new Command<>( + RELOAD, + ImmutableMap.of(CONTEXT, id, "wait", readinessState.toString()), + navigationInfoMapper)); } // Yet to be implemented by browser vendors - private void reload(boolean ignoreCache, ReadinessState readinessState) { - this.bidi.send( + private NavigationResult reload(boolean ignoreCache, ReadinessState readinessState) { + return this.bidi.send( new Command<>( RELOAD, ImmutableMap.of( - CONTEXT, id, "ignoreCache", ignoreCache, "wait", readinessState.toString()))); + CONTEXT, id, "ignoreCache", ignoreCache, "wait", readinessState.toString()), + navigationInfoMapper)); } // Yet to be implemented by browser vendors diff --git a/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextTest.java b/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextTest.java index 4ccfe4c8ca88f..ba50fa9c4854f 100644 --- a/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextTest.java +++ b/java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextTest.java @@ -201,6 +201,36 @@ void canCloseATab() { // TODO: Add a test for closing the last tab once the behavior is finalized // Refer: https://github.com/w3c/webdriver-bidi/issues/187 + @Test + @NotYetImplemented(SAFARI) + @NotYetImplemented(IE) + void canReloadABrowsingContext() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + + String url = server.whereIs("/bidi/logEntryAdded.html"); + browsingContext.navigate(url, ReadinessState.COMPLETE); + + NavigationResult reloadInfo = browsingContext.reload(); + + assertThat(reloadInfo.getNavigationId()).isNotNull(); + assertThat(reloadInfo.getUrl()).contains("/bidi/logEntryAdded.html"); + } + + @Test + @NotYetImplemented(SAFARI) + @NotYetImplemented(IE) + void canReloadWithReadinessState() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + + String url = server.whereIs("/bidi/logEntryAdded.html"); + browsingContext.navigate(url, ReadinessState.COMPLETE); + + NavigationResult reloadInfo = browsingContext.reload(ReadinessState.COMPLETE); + + assertThat(reloadInfo.getNavigationId()).isNotNull(); + assertThat(reloadInfo.getUrl()).contains("/bidi/logEntryAdded.html"); + } + @AfterEach public void quitDriver() { if (driver != null) {