0

尝试与其他用户一起运行 chrome 时出现此错误。我似乎无法弄清楚为什么我会收到错误

程序集目录和 chromedriver.exe 似乎是正确的,但 chrome 浏览器由于某种原因无法启动

Nuget 包 Selenium.Webdriver.ChromeDriver = 81.0.4044.13800

Chrome = 版本 81.0.4044.138(官方版本)(64 位)

 private static RemoteWebDriver OpenChromeBrowser(string userName)
        {
            Console.WriteLine("Entering Chromesetup");
            var driverPath = CommonHelper.AssemblyDirectory;
       

            Console.WriteLine($"Assembly Directory : {driverPath}");
               var service = ChromeDriverService.CreateDefaultService(driverPath); //Error seems to happen here

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

0

这是我对 chrome 的完整调用的大部分内容。您不应该在通话中调用 chromedriver.exe。只需使用目录作为文件的位置。

                    ChromeDriverService service = ChromeDriverService.CreateDefaultService(Path.Combine(GetBasePath, @"bin\Debug\"));
                    ChromeOptions options = new ChromeOptions();
                    options.AddArguments("--incognito");
                    driver = new ChromeDriver(service, options);
                    driver.Manage().Cookies.DeleteAllCookies();


            public static string GetBasePath
    {
        get
        {
            var basePath =
                System.IO.Path.GetDirectoryName((System.Reflection.Assembly.GetExecutingAssembly().Location));
            basePath = basePath.Substring(0, basePath.Length - 10);
            return basePath;
        }
    }
    
于 2020-10-28T13:37:39.167 回答