在弃用DesiredCapabilities的情况下,如何在Selenium Webdriver C#中使用SetCapability?

时间:2018-09-13 12:22:21

标签: c# selenium selenium-webdriver automated-tests

已弃用DesiredCapabilities,如何在Selenium Webdriver C#中使用SetCapability?

我可以这样使用吗?

capacidades = new ChromeOptions();
capacidades.AddAdditionalCapability(@"browserName", @"chrome");

1 个答案:

答案 0 :(得分:0)

在JimEvans的答案中添加一个简单的示例。

禁用Chrome信息栏的简单示例:

private IWebDriver GetChromeDriver()
{
    var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

    //Disable chrome info bar in order to prevent "Chrome is being run by automation software."
    var chromeOption = new ChromeOptions();
    chromeOption.AddArguments("disable-infobars");

    return new ChromeDriver(outPutDirectory, chromeOption);
}