Skip to content

Commit 1eba709

Browse files
authored
[java][bidi]: add browsingContext event onNavigationCommitted (#15560)
1 parent 7565262 commit 1eba709

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

java/src/org/openqa/selenium/bidi/module/BrowsingContextInspector.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,22 @@ public void onBrowsingContextLoaded(Consumer<NavigationInfo> consumer) {
140140
addNavigationEventListener("browsingContext.load", consumer);
141141
}
142142

143-
private void onDownloadWillBegin(Consumer<NavigationInfo> consumer) {
143+
public void onDownloadWillBegin(Consumer<NavigationInfo> consumer) {
144144
addNavigationEventListener("browsingContext.downloadWillBegin", consumer);
145145
}
146146

147-
private void onNavigationAborted(Consumer<NavigationInfo> consumer) {
147+
public void onNavigationAborted(Consumer<NavigationInfo> consumer) {
148148
addNavigationEventListener("browsingContext.navigationAborted", consumer);
149149
}
150150

151-
private void onNavigationFailed(Consumer<NavigationInfo> consumer) {
151+
public void onNavigationFailed(Consumer<NavigationInfo> consumer) {
152152
addNavigationEventListener("browsingContext.navigationFailed", consumer);
153153
}
154154

155+
public void onNavigationCommitted(Consumer<NavigationInfo> consumer) {
156+
addNavigationEventListener("browsingContext.navigationCommitted", consumer);
157+
}
158+
155159
public void onUserPromptClosed(Consumer<UserPromptClosed> consumer) {
156160
if (browsingContextIds.isEmpty()) {
157161
this.bidi.addListener(userPromptClosed, consumer);

java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextInspectorTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.openqa.selenium.bidi.browsingcontext;
1919

2020
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
21+
import static org.openqa.selenium.testing.drivers.Browser.*;
2122

2223
import java.util.List;
2324
import java.util.concurrent.CompletableFuture;
@@ -30,6 +31,7 @@
3031
import org.openqa.selenium.bidi.module.BrowsingContextInspector;
3132
import org.openqa.selenium.testing.JupiterTestBase;
3233
import org.openqa.selenium.testing.NeedsFreshDriver;
34+
import org.openqa.selenium.testing.NotYetImplemented;
3335

3436
class BrowsingContextInspectorTest extends JupiterTestBase {
3537

@@ -213,4 +215,22 @@ void canListenToUserPromptClosedEvent()
213215
assertThat(userPromptClosed.getAccepted()).isTrue();
214216
}
215217
}
218+
219+
@Test
220+
@NeedsFreshDriver
221+
@NotYetImplemented(FIREFOX)
222+
void canListenToNavigationCommittedEvent()
223+
throws ExecutionException, InterruptedException, TimeoutException {
224+
try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) {
225+
CompletableFuture<NavigationInfo> future = new CompletableFuture<>();
226+
227+
BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle());
228+
inspector.onNavigationCommitted(future::complete);
229+
context.navigate(appServer.whereIs("/bidi/logEntryAdded.html"), ReadinessState.COMPLETE);
230+
231+
NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS);
232+
assertThat(navigationInfo.getBrowsingContextId()).isEqualTo(context.getId());
233+
assertThat(navigationInfo.getUrl()).contains("/bidi/logEntryAdded.html");
234+
}
235+
}
216236
}

0 commit comments

Comments
 (0)