From 09873e5b4b91f690091d514874557a2553074227 Mon Sep 17 00:00:00 2001 From: Boris Osipov Date: Tue, 12 Nov 2024 01:04:30 +0300 Subject: [PATCH 1/2] Allow to set DefaultNavigationTimeout via Timeouts.pageLoadTimeout --- src/main/java/org/brit/driver/PlaywrightiumDriver.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/brit/driver/PlaywrightiumDriver.java b/src/main/java/org/brit/driver/PlaywrightiumDriver.java index 9315090..01c72f6 100644 --- a/src/main/java/org/brit/driver/PlaywrightiumDriver.java +++ b/src/main/java/org/brit/driver/PlaywrightiumDriver.java @@ -686,12 +686,14 @@ public Duration getScriptTimeout() { @Override public Timeouts pageLoadTimeout(long time, TimeUnit unit) { - return null; + page.setDefaultNavigationTimeout(Duration.of(time, unit.toChronoUnit()).toMillis()); + return this; } @Override public Timeouts pageLoadTimeout(Duration duration) { - return Timeouts.super.pageLoadTimeout(duration); + page.setDefaultNavigationTimeout(duration.toMillis()); + return this; } @Override From d9a9c8ba82aefe15d5eee7644bcff4f3d7f49936 Mon Sep 17 00:00:00 2001 From: Boris Osipov Date: Thu, 14 Nov 2024 16:02:53 +0300 Subject: [PATCH 2/2] Set timeouts for browserContext() - this allows us to automatically set timeouts for new pages (tabs) opened during test execution. --- src/main/java/org/brit/driver/PlaywrightiumDriver.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/brit/driver/PlaywrightiumDriver.java b/src/main/java/org/brit/driver/PlaywrightiumDriver.java index 01c72f6..92b3647 100644 --- a/src/main/java/org/brit/driver/PlaywrightiumDriver.java +++ b/src/main/java/org/brit/driver/PlaywrightiumDriver.java @@ -649,13 +649,16 @@ public PlaywrightWebdriverTimeouts() { @Override public Timeouts implicitlyWait(long time, TimeUnit unit) { - page.setDefaultTimeout(Duration.of(time, unit.toChronoUnit()).toMillis()); + long millis = Duration.of(time, unit.toChronoUnit()).toMillis(); + page.setDefaultTimeout(millis); + page.context().setDefaultTimeout(millis); return this; } @Override public Timeouts implicitlyWait(Duration duration) { page.setDefaultTimeout(duration.toMillis()); + page.context().setDefaultTimeout(duration.toMillis()); return this; } @@ -686,13 +689,16 @@ public Duration getScriptTimeout() { @Override public Timeouts pageLoadTimeout(long time, TimeUnit unit) { - page.setDefaultNavigationTimeout(Duration.of(time, unit.toChronoUnit()).toMillis()); + long millis = Duration.of(time, unit.toChronoUnit()).toMillis(); + page.setDefaultNavigationTimeout(millis); + page.context().setDefaultNavigationTimeout(millis); return this; } @Override public Timeouts pageLoadTimeout(Duration duration) { page.setDefaultNavigationTimeout(duration.toMillis()); + page.context().setDefaultNavigationTimeout(duration.toMillis()); return this; }