本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeOptions.AddAdditionalCapability方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeOptions.AddAdditionalCapability方法的具体用法?C# ChromeOptions.AddAdditionalCapability怎么用?C# ChromeOptions.AddAdditionalCapability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Chrome.ChromeOptions
的用法示例。
在下文中一共展示了ChromeOptions.AddAdditionalCapability方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeTestRun
public static void BeforeTestRun()
{
ChromeOptions optionChrome = new ChromeOptions();
optionChrome.AddAdditionalCapability("chrome.noWebsiteTestingDefaults", false);
optionChrome.AddAdditionalCapability("chrome.applicationCacheEnabled", false);
Driver = new ChromeDriver();
Driver.Manage().Cookies.DeleteAllCookies();
Driver.Manage().Window.Maximize();
Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5));
}
示例2: PerformInitialize
/// <summary>
/// Performs the initialize of the browser.
/// </summary>
/// <param name="driverFolder">The driver folder.</param>
/// <param name="proxy">The proxy.</param>
/// <returns>
/// The web driver.
/// </returns>
protected override IWebDriver PerformInitialize(string driverFolder, Proxy proxy)
{
var options = new ChromeOptions();
if (!string.IsNullOrWhiteSpace(proxy.HttpProxy))
{
options.AddAdditionalCapability(CapabilityType.Proxy, proxy);
}
return new ChromeDriver(driverFolder, options);
}
示例3: CreateWebDriverWithProfiling
private void CreateWebDriverWithProfiling()
{
if (TestUtilities.IsFirefox(driver))
{
DesiredCapabilities caps = DesiredCapabilities.Firefox();
caps.SetCapability(CapabilityType.EnableProfiling, true);
localDriver = new FirefoxDriver(caps);
}
else if (TestUtilities.IsChrome(driver))
{
ChromeOptions options = new ChromeOptions();
options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true);
localDriver = new ChromeDriver(options);
ICapabilities c = ((IHasCapabilities)localDriver).Capabilities;
}
}
示例4: SetWebDriverToChrome
private void SetWebDriverToChrome()
{
var driver = ChromeDriverService.CreateDefaultService(Browsers + "Chrome" + Helpers._seperator + _chromedriver);
var settings = new ChromeOptions();
settings.AddAdditionalCapability(CapabilityType.SupportsFindingByCss, true);
settings.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
try
{
WebDriver = new ChromeDriver(driver, settings);
}
catch (DriverServiceNotFoundException ex)
{
throw new DriverServiceNotFoundException(ex.Message);
}
}
示例5: InitializeChromeDriver
public static RemoteWebDriver InitializeChromeDriver(Uri serviceUrl)
{
ChromeOptions options = new ChromeOptions();
var perfLoggingPrefs = new Dictionary<string, object> { { "enableNetwork", true }, { "enablePage", true }, { "enableTimeline", false } };
try
{
string perf = ConfigurationManager.AppSettings["ChromeDriver.PerfLogging"];
if ("false" != perf.ToLower())
{
options.AddAdditionalCapability("perfLoggingPrefs", perfLoggingPrefs);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
// Swallow non-existent Configurations
}
try
{
string mobile = ConfigurationManager.AppSettings["ChromeDriver.MobileEmulationDevice"];
if ("false" != mobile.ToLower())
{
options.AddAdditionalCapability("mobileEmulation",
new Dictionary<string, object> {{"deviceName", mobile}});
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
// Swallow non-existent Configurations
}
try
{
options.AddArgument("--lang=" + ConfigurationManager.AppSettings["ChromeDriver.language"]);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
// Swallow non-existent Configurations
}
DesiredCapabilities capabilities = options.ToCapabilities() as DesiredCapabilities;
var loggingPrefs = new Dictionary<string, object> { { "performance", "ALL" }, { "browser", "ALL" } };
try
{
string perf = ConfigurationManager.AppSettings["ChromeDriver.PerfLogging"];
if ("false" != perf.ToLower())
{
capabilities.SetCapability("loggingPrefs", loggingPrefs);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
// Swallow non-existent Configurations
}
return new RemoteWebDriver(serviceUrl, capabilities);
}