From 5dfc5f6f2128d0b7385d6a80706e4f4ce0639c4c Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Mon, 23 Dec 2024 14:59:25 +0530 Subject: [PATCH 1/3] allow setting custom timeout via overloaded constructor --- .../org/openqa/selenium/devtools/DevTools.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/devtools/DevTools.java b/java/src/org/openqa/selenium/devtools/DevTools.java index b83e68f0fd8f0..ed1c29b121e7b 100644 --- a/java/src/org/openqa/selenium/devtools/DevTools.java +++ b/java/src/org/openqa/selenium/devtools/DevTools.java @@ -42,13 +42,19 @@ public class DevTools implements Closeable { private static final Logger LOG = Logger.getLogger(DevTools.class.getName()); private final Domains protocol; - private final Duration timeout = Duration.ofSeconds(10); + private Duration timeout = Duration.ofSeconds(10); private final Connection connection; private SessionID cdpSession = null; public DevTools(Function protocol, Connection connection) { + this(protocol, connection, Duration.ofSeconds(10)); + } + + // overloaded constructor for setting timeout + public DevTools(Function protocol, Connection connection, Duration timeout) { this.connection = Require.nonNull("WebSocket connection", connection); this.protocol = Require.nonNull("CDP protocol", protocol).apply(this); + setTimeout(timeout); } public Domains getDomains() { @@ -212,4 +218,12 @@ private Throwable unwrapCause(ExecutionException e) { public SessionID getCdpSession() { return cdpSession; } + + public void setTimeout(Duration timeout) { + Require.nonNull("Timeout duration", timeout); + if (timeout.isNegative() || timeout.isZero()) { + throw new IllegalArgumentException("Timeout must be positive"); + } + this.timeout = timeout; + } } From 35ddce6ef5d53dd66be9ad7dff61b6e58fa1643a Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Fri, 10 Jan 2025 10:26:07 +0530 Subject: [PATCH 2/3] Revert "allow setting custom timeout via overloaded constructor" This reverts commit 5dfc5f6f2128d0b7385d6a80706e4f4ce0639c4c. --- .../org/openqa/selenium/devtools/DevTools.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/java/src/org/openqa/selenium/devtools/DevTools.java b/java/src/org/openqa/selenium/devtools/DevTools.java index ed1c29b121e7b..b83e68f0fd8f0 100644 --- a/java/src/org/openqa/selenium/devtools/DevTools.java +++ b/java/src/org/openqa/selenium/devtools/DevTools.java @@ -42,19 +42,13 @@ public class DevTools implements Closeable { private static final Logger LOG = Logger.getLogger(DevTools.class.getName()); private final Domains protocol; - private Duration timeout = Duration.ofSeconds(10); + private final Duration timeout = Duration.ofSeconds(10); private final Connection connection; private SessionID cdpSession = null; public DevTools(Function protocol, Connection connection) { - this(protocol, connection, Duration.ofSeconds(10)); - } - - // overloaded constructor for setting timeout - public DevTools(Function protocol, Connection connection, Duration timeout) { this.connection = Require.nonNull("WebSocket connection", connection); this.protocol = Require.nonNull("CDP protocol", protocol).apply(this); - setTimeout(timeout); } public Domains getDomains() { @@ -218,12 +212,4 @@ private Throwable unwrapCause(ExecutionException e) { public SessionID getCdpSession() { return cdpSession; } - - public void setTimeout(Duration timeout) { - Require.nonNull("Timeout duration", timeout); - if (timeout.isNegative() || timeout.isZero()) { - throw new IllegalArgumentException("Timeout must be positive"); - } - this.timeout = timeout; - } } From f20a8eb48148a1b9d8cb843bce468d711a8c5280 Mon Sep 17 00:00:00 2001 From: Navin Chandra Date: Fri, 10 Jan 2025 10:28:36 +0530 Subject: [PATCH 3/3] increase timeout to 30s --- java/src/org/openqa/selenium/devtools/DevTools.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/devtools/DevTools.java b/java/src/org/openqa/selenium/devtools/DevTools.java index b83e68f0fd8f0..11a3207954225 100644 --- a/java/src/org/openqa/selenium/devtools/DevTools.java +++ b/java/src/org/openqa/selenium/devtools/DevTools.java @@ -42,7 +42,7 @@ public class DevTools implements Closeable { private static final Logger LOG = Logger.getLogger(DevTools.class.getName()); private final Domains protocol; - private final Duration timeout = Duration.ofSeconds(10); + private final Duration timeout = Duration.ofSeconds(30); private final Connection connection; private SessionID cdpSession = null;