當前位置: 首頁>>代碼示例>>C#>>正文


C# ChromeOptions.AddAdditionalCapability方法代碼示例

本文整理匯總了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));
 }
開發者ID:piotrekkula,項目名稱:RyanAir,代碼行數:10,代碼來源:Events.cs

示例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);
        }
開發者ID:giacomelli,項目名稱:SpecFlowHelper,代碼行數:19,代碼來源:ChromeBrowser.cs

示例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;
     }
 }
開發者ID:RanchoLi,項目名稱:selenium,代碼行數:16,代碼來源:AvailableLogsTest.cs

示例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);
            }
        }
開發者ID:beeaux,項目名稱:automation-frameworks,代碼行數:17,代碼來源:SharedDriver.cs

示例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);
        }
開發者ID:Blackbaud-LucasWestervelt,項目名稱:uat-kit,代碼行數:61,代碼來源:BaseTest.cs


注:本文中的OpenQA.Selenium.Chrome.ChromeOptions.AddAdditionalCapability方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。