0
votes

Running the most basic selenium test I can think of.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Firefox;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            String path = @"D:\Selenium Webdrivers\ChromeDriver\";
            IWebDriver driver;
            driver = new ChromeDriver(path);
        }
    }
}

I am using,

  • Chrome Version 52.0.2743.82 m
  • ChromeDriver 2.22
  • Selenium WebDriver 2.53.1
  • Selenium WebDriver Support Classes 2.53.1
  • win10 (recent upgrade)

I have tried uninstalling and reinstalling chrome and removing the user profiles.

the error I get is,

Test Name: TestMethod1 Test FullName: UnitTestProject1.UnitTest1.TestMethod1 Test Source: c:\Users\user\Documents\Visual Studio 2013\Projects\UnitTestProject1\UnitTestProject1\UnitTest1.cs : line 13 Test Outcome: Failed Test Duration: 0:00:01.3305496

Result Message: Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception: System.InvalidOperationException: unknown error: chrome failed to start (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 10.0.10586 x86_64) Result StackTrace: at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) 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(String chromeDriverDirectory, ChromeOptions options) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory) at UnitTestProject1.UnitTest1.TestMethod1() in c:\Users\user\Documents\Visual Studio 2013\Projects\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 15

2
driver = new FirefoxDriver(); will work correctly. Seems to be just chrome.user3881000
Is there an older version of Chrome lying around somewhere on the machine you're testing on that WebDriver's picking up and trying to use?Josh

2 Answers

3
votes

Try throwing your chromedriver.exe in your project/solution folder and then appropriately changing your path. That should fix the issue for you.

note: FireFoxDriver works successfully because it's included in the Selenium packages, which is also within your project solution.

0
votes

The solution is now resolved. I was not running visual studio as an administrator. Thank you for your help.