I'm using Selenium in C# and would like to read the client-side logs (like console.log
in javascript).
I'm initializing the ChromeDriver and setting the logging preference to Client:
ChromeOptions options = new ChromeOptions();
options.SetLoggingPreference(LogType.Client, LogLevel.All);
var webDriver = new ChromeDriver(options);
objectContainer.RegisterInstanceAs<IWebDriver>(webDriver);
However, when I try to retrieve the AvailableLogTypes:
var whatever = driver.Manage().Logs.AvailableLogTypes;
browser
and driver
are the only available log types to read from:
When I try to get the Client logs:
var logs = driver.Manage().Logs.GetLog(LogType.Client);
I get an exception:
An exception of type 'System.InvalidOperationException' occurred in WebDriver.dll but was not handled in user code
Additional information: unknown error: log type 'client' not found
Any idea how I can fix this? It seems like it defaults back to browser
and driver
logging at some point but I'm not sure where.
If you want logs like console.log()
, then I think LogType.Browser
is what you need. Just make sure, the browser has those logs
If you don't see other LogType
, like CLIENT
, SERVER
... you can try to enable those log types as the answer in How to obtain native logger in Selenium WebDriver
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With