Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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
OpenQA.Selenium.WebDriverException Message=无法在上启动驱动程序服务http://localhost:port/ 在C#_C#_Google Chrome_Selenium Webdriver_Webdriver_Selenium Chromedriver - Fatal编程技术网

OpenQA.Selenium.WebDriverException Message=无法在上启动驱动程序服务http://localhost:port/ 在C#

OpenQA.Selenium.WebDriverException Message=无法在上启动驱动程序服务http://localhost:port/ 在C#,c#,google-chrome,selenium-webdriver,webdriver,selenium-chromedriver,C#,Google Chrome,Selenium Webdriver,Webdriver,Selenium Chromedriver,我使用的是最新的Selenium.WebDriver NuGet包v3.141.0 最新Selenium.WebDriver.ChromeDriver软件包v80.0.3987.1600 我的chrome版本是80.0.3987.87 chromedriver.exe与我的程序可执行文件位于同一文件夹中 var driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://www.google.com/"); 然后是整个stac

我使用的是最新的Selenium.WebDriver NuGet包v3.141.0

最新Selenium.WebDriver.ChromeDriver软件包v80.0.3987.1600

我的chrome版本是80.0.3987.87

chromedriver.exe与我的程序可执行文件位于同一文件夹中

var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.google.com/");
然后是整个stacktrace-

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=Cannot start the driver service on http://localhost:port/
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.DriverService.Start()
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
   at snow_net.Program.create_chg_mypruit() in C:\Users\username\source\repos\snow-net\Program.cs:line 119
   at snow_net.Program.Main(String[] args) in C:\Users\username\source\repos\snow-net\Program.cs:line 66
编辑: 我也试过了

IWebDriver driver;
            using (driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(@"https://www.google.com/");
            }
它失败了,出现了同样的错误,并尝试了IE和Firefox驱动程序

更新:


所以我在家里(不是在我的公司网络上)尝试了这个方法,它使用了这个精确的代码。。。我被防火墙阻止了吗?

你必须注意以下几件事:

  • 您需要传递整个url,即将
    www
    添加到
    https://google.com
    ,因此有效地将url设置为
    https://www.google.com/
  • 此外,由于已将ChromeDriver实例初始化为
    驱动程序
    ,因此必须仅使用驱动程序实例调用
    导航()
    ,而不使用
    驱动程序
  • 实际上,您的代码块将是:

    var driver = new ChromeDriver();
    driver.Navigate().GoToUrl("https://www.google.com/"); 
    

查看下面的SO帖子是否有帮助我浏览了这篇帖子,我的驱动程序与我的浏览器chrome版本80.0.3987.87(官方版本)(64位)ChromeWebDriver 80.0.3987.1600很遗憾,它没有像我希望的那样工作:(同一问题)persists@scocuzza你能用你当前的代码和我提到的更改来更新这个问题吗?对不起,我的部分有错别字,我已经更新了这个问题,我已经尝试过了
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.google.com/");