diff --git a/java/src/org/openqa/selenium/bidi/module/LogInspector.java b/java/src/org/openqa/selenium/bidi/module/LogInspector.java index 27c2adae27452..c897fd0a1df57 100644 --- a/java/src/org/openqa/selenium/bidi/module/LogInspector.java +++ b/java/src/org/openqa/selenium/bidi/module/LogInspector.java @@ -24,6 +24,7 @@ import java.util.function.Consumer; import org.openqa.selenium.WebDriver; import org.openqa.selenium.bidi.BiDi; +import org.openqa.selenium.bidi.Event; import org.openqa.selenium.bidi.HasBiDi; import org.openqa.selenium.bidi.log.BaseLogEntry; import org.openqa.selenium.bidi.log.ConsoleLogEntry; @@ -36,7 +37,7 @@ import org.openqa.selenium.internal.Require; public class LogInspector implements AutoCloseable { - + private final Event logEntryAddedEvent; private final Set browsingContextIds; private final BiDi bidi; @@ -59,6 +60,7 @@ public LogInspector(Set browsingContextIds, WebDriver driver) { this.bidi = ((HasBiDi) driver).getBiDi(); this.browsingContextIds = browsingContextIds; + this.logEntryAddedEvent = Log.entryAdded(); } public long onConsoleEntry(Consumer consumer) { @@ -165,9 +167,9 @@ public void onLog(Consumer consumer, FilterBy filter) { private long addLogEntryAddedListener(Consumer consumer) { if (browsingContextIds.isEmpty()) { - return this.bidi.addListener(Log.entryAdded(), consumer); + return this.bidi.addListener(this.logEntryAddedEvent, consumer); } else { - return this.bidi.addListener(browsingContextIds, Log.entryAdded(), consumer); + return this.bidi.addListener(browsingContextIds, this.logEntryAddedEvent, consumer); } }