Hi, I am checking the logs created by ChromeDriver and recovered with Selenium and they seem to always be limited to 100k lines.
Code to set the logs:
public static ChromeDriver LocalDriver()
{
ChromeOptions options = new();
options.AddArguments(
// "enable-automation", // turned on by default
// "disable-infobars", //removed long time ago
"disable-notifications",
"start-maximized"
);
options.AddUserProfilePreference("profile.default_content_settings.popups", 0);
//var chromeLocalOptions = new ChromeOptions();
//chromeLocalOptions.UseSpecCompliantProtocol = false;
//chromeLocalOptions.AddAdditionalCapability("w3c", false);
//chromeLocalOptions.AddArgument("enable-automation");
//chromeLocalOptions.AddArgument("disable-infobars");
//chromeLocalOptions.AddArgument("disable-notifications");
//chromeLocalOptions.AddArgument("start-maximized");
//chromeLocalOptions.AddArgument("auto-open-devtools-for-tabs");
//chromeLocalOptions.AddArgument("verbose");
//chromeLocalOptions.AddArgument("log-path=chromedriver.log");
//chromeLocalOptions.AddUserProfilePreference("profile.default_content_settings.popups", 0);
//chromeLocalOptions.AddArgument("headless");
//chromeLocalOptions.AddArgument("remote-debugging-port=9229");
options.AddArgument($"user-agent={userAgent} TestPlansQA");
//chromeLocalOptions.AddArgument("window-size=1920,1080");
//chromeLocalOptions.AddArgument(@"user-data-dir=C:\Users\elgato\AppData\Local\Google\Chrome\User Data");
//chromeLocalOptions.AddArgument(@"profile-directory=Profile 1");
//chromeLocalOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
//chromeLocalOptions.SetLoggingPreference(LogType.Client, LogLevel.All);
//chromeLocalOptions.SetLoggingPreference(LogType.Driver, LogLevel.All);
//chromeLocalOptions.SetLoggingPreference(LogType.Profiler, LogLevel.All);
//chromeLocalOptions.SetLoggingPreference(LogType.Server, LogLevel.All);
#endregion
options.BinaryLocation =
@"C:\Program Files\Chromium\Application\chrome.exe";
//@"C:\chrome-win\chrome.exe";
options.AddArgument("lang=es");
//Dictionary<string, object> perfLogPrefs = new()
//{
// { "traceCategories", "browser,devtools.timeline,devtools" }
//};
//perfLogPrefs.Add("traceCategories", "browser,devtools.timeline,devtools"); // comma-separated trace categories
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
options.SetLoggingPreference(LogType.Client, LogLevel.All);
options.SetLoggingPreference(LogType.Profiler, LogLevel.All);
options.SetLoggingPreference(LogType.Performance, LogLevel.All);
options.SetLoggingPreference(LogType.Server, LogLevel.All);
ChromiumPerformanceLoggingPreferences perfLogPrefs = new();
perfLogPrefs.AddTracingCategories("browser,devtools.timeline,devtools");
options.PerformanceLoggingPreferences = perfLogPrefs;
var chromeService = ChromeDriverService.CreateDefaultService();
chromeService.EnableVerboseLogging = true;
chromeService.HideCommandPromptWindow = false;
chromeService.LogPath = $@"D:\chromelogs\{DateTime.Now.ToFileTime()}.log";
return new ChromeDriver(chromeService, options, TimeSpan.FromSeconds(120))
{
FileDetector = new LocalFileDetector(),
};
Code to retrieve the logs:
foreach (var logtype in scope.Resolve<IWebDriver>().Manage().Logs.AvailableLogTypes)
{
var logEntries = scope.Resolve<IWebDriver>().Manage().Logs.GetLog(logtype);
var filePath = $@"{TestContext.TestResultsDirectory}\{TestContext.TestName}_{logtype}.log";
using (StreamWriter writer = new(filePath))
{
// Write each log entry to the file
foreach (LogEntry entry in logEntries)
writer.WriteLine(entry);
}
TestContext.AddResultFile(filePath);
}
Is this correct? Thank you.