哪里可以使用c#在selenium中找到chromedriver.log。我在哪里可以看到chromedriver的日志文件?

时间:2022-07-25 15:05:19

Where to find chromedriver.log in selenium using c#. Where can i see the log file of chromedriver?

哪里可以使用c#在selenium中找到chromedriver.log。我在哪里可以看到chromedriver的日志文件?

ChromeOptions optn= new ChromeOptions();
optn.AddArgument("--verbose");
optn.AddArgument("--log-path=D:\\chromedriver.log");
var driver = new ChromeDriver(@"D:\Driver\",optn);
driver.Navigate().GoToUrl("https://www.google.co.in/?gfe_rd=cr&ei=aWh0U7WHEJGAuASTuYHIAQ");

I'm using the above code but unable to see the log file in specified location. Please help me to find it

我正在使用上面的代码但无法在指定位置看到日志文件。请帮我找到它

3 个解决方案

#1


16  

I think what you're looking for is something like this:

我认为你要找的是这样的:

var optn = new ChromeOptions();
var service = ChromeDriverService.CreateDefaultService(@"D:\Driver\"); 
service.LogPath = "chromedriver.log";
service.EnableVerboseLogging = true;
var driver = new ChromeDriver(service, optn);
driver.Navigate().GoToUrl("https://www.google.co.in/?gfe_rd=cr&ei=aWh0U7WHEJGAuASTuYHIAQ");

The ChromeOptions is for the browser process itself. Logging goes to the ChromeDriver by setting the ChromeDriverService variables.

ChromeOptions适用于浏览器进程本身。通过设置ChromeDriverService变量,日志记录将转至ChromeDriver。

#2


2  

I've found that it works if you remove the "--" from your arguments. The library code must be adding them. So your code should look like this..

我发现如果从参数中删除“ - ”就可以了。库代码必须添加它们。所以你的代码看起来应该是这样的......

ChromeOptions optn= new ChromeOptions();
optn.AddArgument("verbose");
optn.AddArgument("log-path=D:\\chromedriver.log");
var driver = new ChromeDriver(@"D:\Driver\",optn);
driver.Navigate().GoToUrl("https://www.google.co.in/?gfe_rd=cr&ei=aWh0U7WHEJGAuASTuYHIAQ");

#3


0  

Most easy solution will be -

最简单的解决方案是 -

System.setProperty("webdriver.chrome.logfile", "D:\\chromedriver.log");

#1


16  

I think what you're looking for is something like this:

我认为你要找的是这样的:

var optn = new ChromeOptions();
var service = ChromeDriverService.CreateDefaultService(@"D:\Driver\"); 
service.LogPath = "chromedriver.log";
service.EnableVerboseLogging = true;
var driver = new ChromeDriver(service, optn);
driver.Navigate().GoToUrl("https://www.google.co.in/?gfe_rd=cr&ei=aWh0U7WHEJGAuASTuYHIAQ");

The ChromeOptions is for the browser process itself. Logging goes to the ChromeDriver by setting the ChromeDriverService variables.

ChromeOptions适用于浏览器进程本身。通过设置ChromeDriverService变量,日志记录将转至ChromeDriver。

#2


2  

I've found that it works if you remove the "--" from your arguments. The library code must be adding them. So your code should look like this..

我发现如果从参数中删除“ - ”就可以了。库代码必须添加它们。所以你的代码看起来应该是这样的......

ChromeOptions optn= new ChromeOptions();
optn.AddArgument("verbose");
optn.AddArgument("log-path=D:\\chromedriver.log");
var driver = new ChromeDriver(@"D:\Driver\",optn);
driver.Navigate().GoToUrl("https://www.google.co.in/?gfe_rd=cr&ei=aWh0U7WHEJGAuASTuYHIAQ");

#3


0  

Most easy solution will be -

最简单的解决方案是 -

System.setProperty("webdriver.chrome.logfile", "D:\\chromedriver.log");