Ciprian Jijie
Ciprian Jijie

Reputation: 477

Unit Testing Visual Studio Online Selenium ChromeDriver Exception

I use Selenium ChromeDriver in a Unit Test project to test some action on a web page ...

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

Chrome driver has been installed from nuget

Install-Package Selenium.WebDriver.ChromeDriver -Version 2.28.0.

When build my project in Visual Studio Online I receive some error:

System.InvalidOperationException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.28.455520

Any solution to solve this?

Upvotes: 0

Views: 1113

Answers (4)

Karthikeya
Karthikeya

Reputation: 314

In general chrome will be installed in the path - C:\Program Files (x86)\Google\Chrome\Application

So please check for installation path. If chrome is not in that path then uninstall old one and install chrome using link - http://filehippo.com/download_google_chrome/

The below Nuget packages should be installed

  1. selenium.webdriver
  2. selenium.webdriver.chromedriver

The below code will open chrome and navigate to google page

using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Chrome;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://google.com");
        }
    }
}

Upvotes: 0

Eddie Chen - MSFT
Eddie Chen - MSFT

Reputation: 29976

ChromeDriver cannot find the Chrome binary files just as the error message indicates. Please check and make sure that Chrome Browser is installed on the build agent or test machine which run the test.

Upvotes: 1

JeffC
JeffC

Reputation: 25714

I don't use the command line to install things for NuGet, I use the menu option in VS.

  1. Open VS and click on your project in the Solution Explorer.
  2. Click on Project > Manage NuGet Packages... from the menu,

See what shows as installed here and if there are any updates. You might try uninstalling and reinstall via the menu I described above and see if it helps. I use NuGet as described all the time and don't have this issue.

Upvotes: 1

Gaurang Shah
Gaurang Shah

Reputation: 12940

You haven't set the path of chromedriver binary in System PATH variable, this how you can do it in code. Do it before you initialize the driver object.

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

Upvotes: -1

Related Questions