diff --git a/java/src/org/openqa/selenium/devtools/events/CdpEventTypes.java b/java/src/org/openqa/selenium/devtools/events/CdpEventTypes.java index 52d3a9fa0fa3d..960a2b289f805 100644 --- a/java/src/org/openqa/selenium/devtools/events/CdpEventTypes.java +++ b/java/src/org/openqa/selenium/devtools/events/CdpEventTypes.java @@ -55,10 +55,10 @@ public void consume(ConsoleEvent event) { } @Override - public void initializeListener(HasLogEvents loggable) { - Require.precondition(loggable instanceof HasDevTools, "Loggable must implement HasDevTools"); + public void initializeListener(WebDriver webDriver) { + Require.precondition(webDriver instanceof HasDevTools, "Loggable must implement HasDevTools"); - DevTools tools = ((HasDevTools) loggable).getDevTools(); + DevTools tools = ((HasDevTools) webDriver).getDevTools(); tools.createSessionIfThereIsNotOne(); tools.getDomains().events().addConsoleListener(handler); @@ -87,16 +87,14 @@ public void consume(Void event) { } @Override - public void initializeListener(HasLogEvents loggable) { - Require.precondition(loggable instanceof WebDriver, "Loggable must be a WebDriver"); - Require.precondition(loggable instanceof HasDevTools, "Loggable must implement HasDevTools"); + public void initializeListener(WebDriver driver) { + Require.precondition(driver instanceof HasDevTools, "Loggable must implement HasDevTools"); - DevTools tools = ((HasDevTools) loggable).getDevTools(); + DevTools tools = ((HasDevTools) driver).getDevTools(); tools.createSessionIfThereIsNotOne(); tools.getDomains().javascript().pin("__webdriver_attribute", script); - WebDriver driver = (WebDriver) loggable; // And add the script to the current page ((JavascriptExecutor) driver).executeScript(script); diff --git a/java/src/org/openqa/selenium/logging/EventType.java b/java/src/org/openqa/selenium/logging/EventType.java index 2d07c9dc20ffc..cad3c05ae4b46 100644 --- a/java/src/org/openqa/selenium/logging/EventType.java +++ b/java/src/org/openqa/selenium/logging/EventType.java @@ -17,11 +17,13 @@ package org.openqa.selenium.logging; +import org.openqa.selenium.WebDriver; + @FunctionalInterface public interface EventType { void consume(X event); - default void initializeListener(HasLogEvents loggable) { + default void initializeListener(WebDriver webDriver) { // no-op } }