Closed
Description
What happened?
DevTools console entries fetched by Selenium DevTools support have value equals to "null" if are RemoteObject.Type.OBJECT
Through debugging Selenium's code it seems that in this place mapping is incorrectly performed and getValue always defaults to null.
I would like to log DevTools messages as 'they are' for further debugging in case of application defect occurence.
Look at attached images - here is my tested application devtools console tab with Intellij's debug on breakpoint
ModifiedArgs are later forwarded to customListener and original args are no longer available.
How can we reproduce the issue?
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.devtools.v106.log.Log;
import org.openqa.selenium.devtools.v106.network.Network;
import java.util.Optional;
class DevToolsEventsTest {
public static void main(String[] args) {
WebDriver driver = null;
try {
//Init WebDriver
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
//Init DevTools
((HasDevTools) driver).maybeGetDevTools().ifPresent(devTools -> {
devTools.createSessionIfThereIsNotOne();
devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.send(Log.enable());
//Add Listeners
devTools.getDomains().events().addConsoleListener(consoleEvent -> System.out.printf("[consoleEvent] %s%n", consoleEvent));
});
//Trigger consoleEvents
((JavascriptExecutor) driver).executeScript("console.log(\"simple\", 1, \"test\", true)");
((JavascriptExecutor) driver).executeScript("console.log(\"array\", [1, 2, 3])");
((JavascriptExecutor) driver).executeScript("console.log(\"object\", { a: 1 })");
((JavascriptExecutor) driver).executeScript("console.log(\"nested object\", { a: { b: 1 } })");
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
if (driver != null) {
driver.quit();
}
}
}
}
Relevant log output
> Task :DevToolsEventsTest.main()
12:39:07 [main] [] DEBUG ResolutionCache - Resolution chrome=108 in cache (valid until 13:07:27 09/12/2022 CET)
12:39:07 [main] [] DEBUG ResolutionCache - Resolution chrome108=108.0.5359.71 in cache (valid until 16:36:58 09/12/2022 CET)
12:39:07 [main] [] INFO WebDriverManager - Using chromedriver 108.0.5359.71 (resolved driver for Chrome 108)
12:39:07 [main] [] DEBUG WebDriverManager - Driver chromedriver 108.0.5359.71 found in cache
12:39:07 [main] [] INFO WebDriverManager - Exporting webdriver.chrome.driver as C:\Users\Wojciech\.cache\selenium\chromedriver\win32\108.0.5359.71\chromedriver.exe
Starting ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}) on port 54167
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Dec 09, 2022 12:39:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
Dec 09, 2022 12:39:11 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 108, so returning the closest version found: 106
Dec 09, 2022 12:39:11 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 108 of 106
[consoleEvent] 2022-12-09T11:39:12.035Z [log] [["simple", 1, "test", true]]
[consoleEvent] 2022-12-09T11:39:12.095Z [log] [["object", null]]
[consoleEvent] 2022-12-09T11:39:12.062Z [log] [["array", null]]
[consoleEvent] 2022-12-09T11:39:12.141Z [log] [["nested object", null]]
Operating System
Windows 10
Selenium version
Java 4.5.0
What are the browser(s) and version(s) where you see this issue?
Chrome 108
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 108.0.5359.71
Are you using Selenium Grid?
No