File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
java/test/org/openqa/selenium/bidi/browsingcontext Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -254,4 +254,29 @@ void canListenToDownloadWillBeginEvent()
254254 assertThat (downloadInfo .getSuggestedFilename ()).isEqualTo ("file_1.txt" );
255255 }
256256 }
257+
258+ @ Test
259+ @ NeedsFreshDriver
260+ @ NotYetImplemented (FIREFOX )
261+ void canListenToNavigationFailedEvent ()
262+ throws ExecutionException , InterruptedException , TimeoutException {
263+ try (BrowsingContextInspector inspector = new BrowsingContextInspector (driver )) {
264+ CompletableFuture <NavigationInfo > future = new CompletableFuture <>();
265+
266+ inspector .onNavigationFailed (future ::complete );
267+
268+ BrowsingContext context = new BrowsingContext (driver , driver .getWindowHandle ());
269+ try {
270+ context .navigate (
271+ "http://invalid-domain-that-does-not-exist.test/" , ReadinessState .COMPLETE );
272+ } catch (Exception e ) {
273+ // Expect an exception due to navigation failure
274+ }
275+
276+ NavigationInfo navigationInfo = future .get (5 , TimeUnit .SECONDS );
277+ assertThat (navigationInfo .getBrowsingContextId ()).isEqualTo (context .getId ());
278+ assertThat (navigationInfo .getUrl ())
279+ .isEqualTo ("http://invalid-domain-that-does-not-exist.test/" );
280+ }
281+ }
257282}
You can’t perform that action at this time.
0 commit comments