Selenium chrome failed to start

▼魔方 西西 提交于 2020-12-15 06:55:22

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/38635496/selenium-chrome-failed-to-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!