c# - 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
解决方案
推荐阅读
- android - 如何使应用程序在主屏幕上可见(最小化时)?
- bigdata - Kusto 表可以有多个更新策略吗?
- javascript - 键入包装原生输入元素的 React 组件
- python - 用于注释多个点的循环?
- spring - Spring Boot:为什么在表单提交后£符号被转义?
- entity-framework - 是否可以组合两个不同类型的 IQueryable?
- c# - 尝试创建类型为“xxx”的控制器时发生错误。确保控制器有一个无参数的公共构造函数。忍者
- ios - (BLE) 无法将数据写入 iOS 上的特征
- polygon - 自定义标记png文件和多边形不能同时显示?或者怎么做?
- python - 如何获得张量值