Selenium Web驱动程序V.3.14中的DesiredCapabilities已过时。如何在C#中编写Selenium网格的代码?

时间:2018-09-19 21:46:12

标签: c# selenium-webdriver selenium-grid

我有以下代码。我将Selenium Web驱动程序更新为v3.14,它显示了过时和错误消息。

DesiredCapabilities capabilities; --deprecated

capabilities = DesiredCapabilities.Chrome(); --has the error for Selennium wen driver v3.14

capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));

Uri uri = new Uri(hub url);

_driver = new RemoteWebDriver(uri, capabilities, TimeSpan.FromSeconds(120)); 


From class RemoteWebDriver in OpenQA.Selenium.Remote, it still has the ICapabilities parameter

public RemoteWebDriver(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout);

我看到了一些使用Chrome选项的帖子。但是我仍然不能使它适用于硒网格。有想法吗?

1 个答案:

答案 0 :(得分:0)

以下内容应该可以正常工作:

ChromeOptions options = new ChromeOptions();
options.PlatformName = "windows";

Uri uri = new Uri(hub url);

_driver = new RemoteWebDriver(uri, options.ToCapabilities(), TimeSpan.FromSeconds(120));