【发布时间】:2021-01-07 20:34:33
【问题描述】:
我目前正在使用 C# 通过 Azure DevOps 管道运行 Selenium 测试。 我对编写 ChromeDriver 日志的代码进行了更改,这需要更改为使用 ChromeDriverService。
string binaryDir = Manager.GetWebDriver(Manager.BrowserType.CHROME,os,browser);
if (options == null) options = new ChromeOptions();
options.AddUserProfilePreference("download.default_directory", ExtentReporter.ReportDir);
options.SetLoggingPreference(LogType.Browser, LogLevel.Info);
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Ignore;
Console.WriteLine("Chrome Logging path: "+chromeLogPath);
var service = ChromeDriverService.CreateDefaultService(binaryDir);
service.LogPath = chromeLogPath;
service.EnableVerboseLogging = true;
_driver = new ChromeDriver(service, options);
_driver.Manage().Window.Maximize();
return _driver;
进行此更改后,chromedriver 无法再打开并出现以下错误: OpenQA.Selenium.WebDriverException : 无法在 http://localhost:52257/ 上启动驱动程序服务
我还从代理目录中复制了编译后的代码并通过命令行执行它,它能够运行所有测试。但是当通过代理工作目录中的命令行执行时,ChromeDriverService 抛出了先前的异常。
我认为这个问题与 ChromeDriver 日志的创建有关,但我也在 Agent Work 目录中生成文件,没有任何错误。
如果之前有任何 WebDriveService 或通过 Azure DevOps 生成 ChromeDriver 日志的经验,我们将不胜感激。
【问题讨论】:
标签: selenium azure-devops selenium-chromedriver