我正在启动我的硒驱动的无头chrome:
var options = new ChromeOptions();
options.AcceptInsecureCertificates = true;
options.AddArgument("--disable-gpu");
options.AddArgument("--no-sandbox");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--disable-web-security");
options.AddArgument("--allow-insecure-localhost");
options.AddArgument("--allow-running-insecure-content");
options.AddArgument("--acceptInsecureCerts=true");
options.AddArgument("--proxy-server='direct://'");
options.AddArgument("--proxy-bypass-list=*");
options.AddArgument("--disable-extensions");
options.AddArgument("--disable-infobars");
options.AddArgument("--window-size=1920,1080");
options.AddArgument("--incognito");
options.AddArgument("--headless");
options.AddArgument("--log-level=ALL");
options.AddArgument("log-path=c:\chromedriver.log");
options.SetLoggingPreference(OpenQA.Selenium.LogType.Driver, OpenQA.Selenium.LogLevel.All);
var svc = ChromeDriverService.CreateDefaultService();
svc.Port = RandomHelper.Randomiser.Next(29700, 29900);
Context.Driver = new ChromeDriver(svc, options, TimeSpan.FromMinutes(2));
但是,在运行(看到成功的测试输出 - 失败和通过测试(后,我在c:chromedriver.log
上看到没有文件。
我在做什么错?
真正通过硒发展而感到沮丧,但找到了如何与Chromedriver登录:
var options = new ChromeOptions();
options.AcceptInsecureCertificates = true;
options.AddArgument("--disable-gpu");
options.AddArgument("--no-sandbox");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--disable-web-security");
options.AddArgument("--allow-insecure-localhost");
options.AddArgument("--allow-running-insecure-content");
options.AddArgument("--acceptInsecureCerts=true");
options.AddArgument("--proxy-server='direct://'");
options.AddArgument("--proxy-bypass-list=*");
options.AddArgument("--disable-extensions");
options.AddArgument("--disable-infobars");
options.AddArgument("--window-size=1920,1080");
options.AddArgument("--incognito");
options.AddArgument("--headless");
options.AddArgument("--log-level=ALL");
options.AddArgument("log-path=c:\chromedriver.log");
options.SetLoggingPreference(OpenQA.Selenium.LogType.Driver, OpenQA.Selenium.LogLevel.All);
var svc = ChromeDriverService.CreateDefaultService();
svc.Port = RandomHelper.Randomiser.Next(29700, 29900);
svc.LogPath = @"c:chromedriver.log";
svc.EnableVerboseLogging = true;
options.SetLoggingPreference(LogType.Browser, LogLevel.All);
options.SetLoggingPreference(LogType.Client, LogLevel.All);
options.SetLoggingPreference(LogType.Driver, LogLevel.All);
options.SetLoggingPreference(LogType.Profiler, LogLevel.All);
options.SetLoggingPreference(LogType.Server, LogLevel.All);
Context.Driver = new ChromeDriver(svc, options, TimeSpan.FromMinutes(2));