首页 > 解决方案 > OpenQA.Selenium.WebDriverException:无法在 http://localhost:50343/ 上启动驱动程序服务

问题描述

我已尝试从 Activity Monitor (Mac) 中清除 Chrome 驱动程序并重新运行测试。这没用。我经常看到这个问题发布,但到目前为止没有一个解决方案有效,并且都是基于 Windows 的。我正在使用 C# 和 Visual Studio 以及 Mac。

请参阅下面的堆栈跟踪:

   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)

Please see the browser code below: 

**BROWSER.CS**


public enum Drivers
    { 
        Chrome,

    }
    #endregion

    ** Class containing browser driver setup, URL setup, Waits, find element definition, and browser manipulation methods**

    public static class Browser
    {
        #region Driver Instantiation

        static IWebDriver _webDriver;


        public static ISearchContext Driver { get { return _webDriver; } }


 **Returns the driver executable application**

internal static IWebDriver GetDriver(Drivers driver)
        {
            switch (driver)
            {
                case Drivers.Chrome:

                    return new ChromeDriver(@"/Users/wsmith/Projects/Github/folio-quality-assurance/Folio.Selenium.Framework");

                default:
                    throw new NotImplementedException("I do not know the driver you specified.");
            }
        }
        #endregion

        #region Initialize Browser

**Initializes the webdriver, opens the browser window. This is called in the test fixtures to set up before running the tests**

        public static void Initialize()
        {
            _webDriver = GetDriver(Drivers.Chrome);
            _webDriver.Manage().Window.Maximize();
            Goto("");
        }
        #endregion

        #region URL

标签: c#seleniumselenium-webdriverselenium-chromedriver

解决方案


推荐阅读