OpenQA.Selenium.WebDriverException Message=Cannot start the driver service on http://localhost:port/ using ChromeDriver Chrome through Selenium in C#

0

I am using latest Selenium.WebDriver NuGet package v3.141.0

latest Selenium.WebDriver.ChromeDriver package v80.0.3987.1600

my chrome version is 80.0.3987.87

the chromedriver.exe is in the same folder as my program executable

var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.google.com/");
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port #
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.

followed by the whole 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

edit: i have also tried

IWebDriver driver;
            using (driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl(@"https://www.google.com/");
            }

which fails with the same error and tried the IE and Firefox drivers as well

Update:

So i tried this at home (not on my companies network) and it worked with this exact code... am i being blocked by firewall ?

c#
google-chrome
selenium-webdriver
webdriver
selenium-chromedriver
asked on Stack Overflow Feb 11, 2020 by scocuzza • edited Feb 13, 2020 by scocuzza

1 Answer

0

You have to take care of a few things:

  • You need to pass the entire url, i.e. add www to https://google.com, so effectively the url will be https://www.google.com/.
  • Additionally, as you have initialized the instance of ChromeDriver as driver, you have to invoke Navigate() with the driver instance only, but not with drive.
  • Effectively your code block will be:

    var driver = new ChromeDriver();
    driver.Navigate().GoToUrl("https://www.google.com/"); 
    
answered on Stack Overflow Feb 11, 2020 by DebanjanB • edited Feb 11, 2020 by DebanjanB

User contributions licensed under CC BY-SA 3.0