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


C# ChromeOptions.AddExcludedArgument方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.Chrome.ChromeOptions.AddExcludedArgument方法的典型用法代碼示例。如果您正苦於以下問題:C# ChromeOptions.AddExcludedArgument方法的具體用法?C# ChromeOptions.AddExcludedArgument怎麽用?C# ChromeOptions.AddExcludedArgument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.Chrome.ChromeOptions的用法示例。


在下文中一共展示了ChromeOptions.AddExcludedArgument方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: _CreateInstance

        private static IWebDriver _CreateInstance(DesiredCapabilities caps, Drivers driver)
        {
            IWebDriver _webdriver = null;
            if (caps == null) {
                //
                // Loaded default caps for RemoteWebDriver from Selenium.Tests.dll.config in current Dll directory
                // See brian.ku about user/key
                //
                caps = new DesiredCapabilities();
                caps.SetCapability("browserstack.user", ConfigurationManager.AppSettings["browserstack.user"]);
                caps.SetCapability("browserstack.key", ConfigurationManager.AppSettings["browserstack.key"]);
                caps.SetCapability("browser", ConfigurationManager.AppSettings["browser"]);
                caps.SetCapability("browser_version", ConfigurationManager.AppSettings["browser_version"]);
                caps.SetCapability("os", ConfigurationManager.AppSettings["os"]);
                caps.SetCapability("os_version", ConfigurationManager.AppSettings["os_version"]);
                caps.SetCapability("resolution", ConfigurationManager.AppSettings["resolution"]);
                caps.SetCapability("browserstack.debug", ConfigurationManager.AppSettings["browserstack.debug"]);
                caps.SetCapability("browserstack.local", ConfigurationManager.AppSettings["browserstack.local"]);
            }
            switch (driver) {
            case Drivers.IEDriver:
                InternetExplorerDriverService ieService = InternetExplorerDriverService.CreateDefaultService();
                _webdriver = new InternetExplorerDriver(ieService, new InternetExplorerOptions(), TimeSpan.FromSeconds(3 * 60));
                break;
            case Drivers.ChromeDriver:
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.AddExcludedArgument("ignore-certifcate-errors");
                chromeOptions.AddArgument("test-type");
                _webdriver = new ChromeDriver(chromeOptions);
                _webdriver.Manage().Window.Maximize();
                break;
            case Drivers.FirefoxDriver:
                FirefoxProfile profile = new FirefoxProfile();
                _webdriver = new FirefoxDriver(profile);
                _webdriver.Manage().Window.Maximize();
                break;
            case Drivers.BrowserStack:
                caps.SetCapability("ensureCleanSession", true);
                _webdriver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["remotewebdriver_url"]), caps);
                //_webdriver.Manage().Window.Maximize();
                break;
            case Drivers.LocalStack:
                //
                // Start the local BrowserStack proxy for cloud browser access
                //
                bool bConnected = false;
                do {
                    //
                    // Reset the stdout capture
                    //
                    sbOutput = new StringBuilder();

                    //
                    // check if connection succeeeded
                    //
                    bConnected = LaunchBrowserStackLocalProcess();
                } while (!bConnected);

                _webdriver = new RemoteWebDriver(new Uri(ConfigurationManager.AppSettings["remotewebdriver_url"]), caps, TimeSpan.FromMinutes(5.0));
                break;
            }
            //
            // Set an implicit timeout for all FindElements
            //
            _webdriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Factory.DefaultTimeoutValue));

            return _webdriver;
        }
開發者ID:buonan,項目名稱:SeleniumTests,代碼行數:68,代碼來源:Factory.cs


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