简体   繁体   中英

Selenium chrome failed to start

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\\UnitTestProjec t1\\UnitTest1.cs:line 15

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM