Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Google Chrome Selenium URL导航与二进制定位_C#_Selenium_Selenium Chromedriver - Fatal编程技术网

C#Google Chrome Selenium URL导航与二进制定位

C#Google Chrome Selenium URL导航与二进制定位,c#,selenium,selenium-chromedriver,C#,Selenium,Selenium Chromedriver,向社会各界致意, 我的问题很简单。我有以下五行代码,我不明白为什么Google Chrome在使用自定义二进制位置时不启动Google.com var Chrome = new ChromeOptions(); Chrome.AddArgument("no-sandbox"); Chrome.BinaryLocation = @"C:\GoogleChrome\chrome.exe"; ChromeDriver driver = n

向社会各界致意,

我的问题很简单。我有以下五行代码,我不明白为什么Google Chrome在使用自定义二进制位置时不启动Google.com

        var Chrome = new ChromeOptions();
        Chrome.AddArgument("no-sandbox");
        Chrome.BinaryLocation = @"C:\GoogleChrome\chrome.exe";
        ChromeDriver driver = new ChromeDriver(@"C:\ChromeDriver", Chrome);
        driver.Navigate().GoToUrl("https://www.google.com");
有什么想法吗?我得到的只是Google Chrome启动时默认的chromedriver URL“数据:,

为什么在使用Chrome.BinaryLocation时driver.navigate命令不起作用?如果我把那句话注释掉,那就行了

我正在使用以下工具:

  • 视窗7
  • Visual Studio社区版2017
  • 谷歌浏览器版本67
  • 铬驱动2.41
  • .NET 4.5绑定

    • 嘿,我认为你不需要二进制定位

      也许Chrome已经是一种类型了

      试试这个:

      ChromeOptions options = new ChromeOptions();
      options.AddArgument("no-sandbox");
      var driver = new ChromeDriver(@"C:\GoogleChrome", options);
      driver.Navigate().GoToUrl("https://www.google.com");
      

      好的,我找到了这个问题的答案。我不知道为什么Firefox、Chrome或其他基于Chrome的浏览器的可移植版本不能以这种方式运行,但我解决了这个问题,将企业安装文件从Chrome的程序文件复制到计算机上的另一个目录,然后将Selenium脚本指向使用该二进制位置。然后它工作得很好

      将Chrome指向自定义Chrome配置文件位置也很有用,这样可以防止更多Chrome应用程序使用本地用户的AppData文件夹

      如果有人对完成相同的任务感兴趣,我可以提供一些完成此任务的示例代码。请给我留言了解更多细节