Hello Team,
I am facing some strange issue while using the Selenium WebDriver and C# with the Performance Logs of Chrome. We have to extract the network traffic in our use case.
When I am using the Webdriver with Java I am able to extract the Performance Logs but it does not work with c#.
Following is C# Configuration :
ChromeOptions capabilities = new ChromeOptions();
capabilities.BrowserVersion = "114.0";
Dictionary<string, object> ltOptions = new Dictionary<string, object>();
ltOptions.Add("username", "user");
ltOptions.Add("accessKey", "key");
ltOptions.Add("platformName", "Windows 10");
ltOptions.Add("build", "TEST");
ltOptions.Add("project", "Testing");
ltOptions.Add("name", runName);
ltOptions.Add("network", true);
ltOptions.Add("seCdp", true);
ltOptions.Add("tunnel", true);
ltOptions.Add("w3c", true);
capabilities.AddAdditionalOption("LT:Options", ltOptions);
var perfLoggingPrefs = new ChromiumPerformanceLoggingPreferences
{
IsCollectingNetworkEvents = true,
IsCollectingPageEvents = false
};
capabilities.SetLoggingPreference(LogType.Performance, LogLevel.All);
capabilities.PerformanceLoggingPreferences = perfLoggingPrefs;
and the Code:
ReadOnlyCollection<LogEntry> logs =_driver.Manage().Logs.GetLog(LogType.Performance);
System.Console.WriteLine("Found:" + logs.Count);
And Get the Error: OpenQA.Selenium.WebDriverArgumentException : invalid argument: log type ‘performance’ not found (Session info: chrome=114.0.5735.16)
I am sending the same configuration using Java but I am able to Extract the logs and I used some other Remote Services and Still can fetch the Logs.
Can you Please try at your end as well and see what might be wrong or i need to change something from my side.
One More hint or workAround you need to make in the C# library regarding the remoteDriver as it miss out the getLogs
//WorkAround for Registering Log in Remote Instance.
IReadOnlyDictionary<string, CommandInfo> logCommands = new Dictionary<string, CommandInfo>
{
{DriverCommand.GetAvailableLogTypes,new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/log/types")},
{DriverCommand.GetLog,new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/log")}
};
var customCommandDriver = driver as ICustomDriverCommandExecutor;