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


C# Chrome.ChromeOptions類代碼示例

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


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

示例1: TestHappyPathChrome

 public void TestHappyPathChrome()
 {
     ChromeOptions co = new ChromeOptions();
     co.AddArgument("--test-type");
     ChromeDriver cd = new ChromeDriver("C:\\Users\\ehelin\\Downloads\\chromedriver_win32", co);
     TestHappyPath(cd);
 }
開發者ID:ehelin,項目名稱:TgimbaSeleniumTests,代碼行數:7,代碼來源:DesktopHappyPath.cs

示例2: Login

        public void Login(String loginUrl)
        {
            var options = new ChromeOptions();
            options.AddArguments("--test-type", "--start-maximized");
            options.AddArguments("--test-type", "--ignore-certificate-errors");
            options.BinaryLocation = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
            driver = new ChromeDriver("C:\\Program Files (x86)\\Google\\Chrome\\Application", options);

            driver.Navigate().GoToUrl(loginUrl);

            int timeout = 0;
            while (driver.FindElements(By.ClassName("logbox")).Count == 0 && timeout < 500)
            {
                Thread.Sleep(1);
                timeout++;

            }

            IWebElement element = driver.FindElement(By.ClassName("logbox"));

            IWebElement ElName = element.FindElement(By.Name("username"));
            ElName.Clear();
            ElName.SendKeys(loginName);
            IWebElement ElPassword = element.FindElement(By.Id("password"));
            ElPassword.Clear();
            ElPassword.SendKeys(loginPassword);
            IWebElement ElLogin = element.FindElement(By.Id("IBtnLogin"));
            ElLogin.Click();
        }
開發者ID:denisefan28,項目名稱:Wind,代碼行數:29,代碼來源:UrlLabel.cs

示例3: Launch

        internal void Launch(bool mobile, string url = "https://www.bing.com/") {
            Quit();
            _viewModel.ResetProfileCommand.RaiseCanExecuteChanged();

            ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder);
            service.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();
            options.AddArgument("start-maximized");
            options.AddArgument("user-data-dir=" + App.Folder + "profile");

            if (mobile)
                options.EnableMobileEmulation("Google Nexus 5");

            try {
                _driver = new ChromeDriver(service, options);
                _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));

                _builder = new Actions(_driver);

                LogUpdate("Launching Chrome " + (mobile ? "Mobile" : "Desktop"), Colors.CadetBlue);

                if (url != null)
                    _driver.Navigate().GoToUrl(url);
            }
            catch (Exception ex) {
                LogUpdate("Error Launching Chrome " + (mobile ? "Mobile" : "Desktop") + "\r\n" + ex.Message, Colors.Red);
                service.Dispose();
            }
        }
開發者ID:dawson-freddie30,項目名稱:binginator,代碼行數:30,代碼來源:MainModel.cs

示例4: switch

		/// <summary>
		/// Get a RemoteWebDriver
		/// </summary>
		/// <param name="browser">the Browser to test on</param>
		/// <param name="languageCode">The language that the browser should accept.</param>
		/// <returns>a IWebDriver</returns>
		IWebDriver IWebDriverFactory.GetWebDriver(Browser browser, string languageCode)
		{
			//What browser to test on?s
			IWebDriver webDriver;
			switch (browser.Browserstring.ToLowerInvariant())
			{
				case "firefox":
					var firefoxProfile = new FirefoxProfile();
					firefoxProfile.SetPreference("intl.accept_languages", languageCode);
					webDriver = new FirefoxDriver(firefoxProfile);
					break;
				case "chrome":
					ChromeOptions chromeOptions = new ChromeOptions();
					chromeOptions.AddArguments("--test-type", "--disable-hang-monitor", "--new-window", "--no-sandbox", "--lang=" + languageCode);
					webDriver = new ChromeDriver(chromeOptions);
					break;
				case "internet explorer":
					webDriver = new InternetExplorerDriver(new InternetExplorerOptions { BrowserCommandLineArguments = "singleWindow=true", IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true, EnablePersistentHover = false });
					break;
				case "phantomjs":
					webDriver = new PhantomJSDriver(new PhantomJSOptions() {});
					break;
				default:
					throw new NotSupportedException("Not supported browser");
			}

			return webDriver;
		}
開發者ID:florianwittmann,項目名稱:regtesting,代碼行數:34,代碼來源:LocalWebDriverFactory.cs

示例5: CreateDriver

 public static IWebDriver CreateDriver()
 {
     ChromeOptions options = new ChromeOptions();
     options.AddArgument("--disable-cache");
     var driver = new ChromeDriver(options);
     return driver;
 }
開發者ID:FaisalZ,項目名稱:FiVES,代碼行數:7,代碼來源:Tools.cs

示例6: Start

        public void Start()
        {
            var options = new ChromeOptions();
              options.AddArgument("--test-type");

              Instance = new RemoteWebDriver(ChromeDriver.BaseUrl, options.ToCapabilities());
        }
開發者ID:agross,項目名稱:mspec-samples,代碼行數:7,代碼來源:Browser.cs

示例7: InitializeDriver

        public virtual void InitializeDriver()
        {
            InitializeSettings();

            switch (BrowserType)
            {
                case BrowserType.Chrome:
                    var chromeOptions = new ChromeOptions();
                    chromeOptions.AddArguments(new string[] { "--no-sandbox", "test-type", "--start-maximized" });
                    var chromeDriverService = ChromeDriverService.CreateDefaultService();
                    chromeDriverService.HideCommandPromptWindow = false;
                    Context.Driver = new ChromeDriver(chromeDriverService, chromeOptions, TimeSpan.FromSeconds(300.0));
                break;
                case BrowserType.Firefox:
                    var capabilities = new DesiredCapabilities();
                    capabilities.SetCapability(CapabilityType.UnexpectedAlertBehavior, "dismiss");
                    Context.Driver = new FirefoxDriver(capabilities);
                break;

            }

            Context.Browser = new Browser();
            Context.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Context.Settings.WaitTimeout));
            Context.Driver.Navigate().GoToUrl("about:blank");
            Context.Driver.SwitchTo().Window(Context.Driver.WindowHandles.First());
        }
開發者ID:alexx-ivanoff,項目名稱:StreamTVautomation,代碼行數:26,代碼來源:TestFixtureBase.cs

示例8: InboxModel

        public InboxModel(string username, string password, BackgroundWorker bw, bool tv)
        {
            ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder);
            service.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();
            options.AddArgument("start-maximized");
            options.AddArgument("user-data-dir=" + App.Folder + "profileIB");

            IWebDriver driver = new ChromeDriver(service, options);
            driver.Navigate().GoToUrl("http://www.inboxdollars.com");

            try
            {
                driver.FindElement(By.Id("loginname")).Clear();
                driver.FindElement(By.Id("pwd")).Clear();
                driver.FindElement(By.Id("loginname")).SendKeys(username);
                driver.FindElement(By.Id("pwd")).SendKeys(password);
                Helpers.wait(1000);
                driver.FindElement(By.ClassName("submit2")).Click();
            }
            catch { }

            try
            {
                if (driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Text != "0")
                {
                    driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Click();
                }
            }
            catch { }

            if (!tv)
            {
                try
                {
                    driver.FindElement(By.ClassName("videos")).Click();
                    videos(driver);
                }
                catch { }
            }
            else if (tv)
            {
                try
                {
                    driver.FindElement(By.ClassName("tv")).Click();
                    Helpers.wait(2000);
                    Helpers.ByClass(driver, "jw-icon");
                    while (true)
                    {
                        try
                        {
                            driver.FindElement(By.Id("tvStillTherePopupContinue")).Click();
                        }
                        catch { }
                    }
                }
                catch { }
            }
        }
開發者ID:XelGar256,項目名稱:Scrap,代碼行數:60,代碼來源:InboxModel.cs

示例9: GetChromeOptions

 private static ChromeOptions GetChromeOptions()
 {
     ChromeOptions option = new ChromeOptions();
     option.AddArgument("start-maximized");
     option.Proxy = null;
     return option;
 }
開發者ID:rohanbaraskar,項目名稱:SummerOutreachWebdriver,代碼行數:7,代碼來源:InitializeWebDriver.cs

示例10: Host

        public Host()
        {
            // Hack
            int retryCount = 3;
            while (true)
            {
                try
                {
                    var options = new ChromeOptions();
                    options.AddArguments("test-type");

                    var service = ChromeDriverService.CreateDefaultService(@"..\..\Scaffolding\WebDriver");
                    service.HideCommandPromptWindow = false;
                    WebDriver = new ChromeDriver(service, options);
                    WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

                    Page = new Page(WebDriver);
                    Page.GotoUrl("Home");
                    break;
                }
                catch
                {
                    if (retryCount-- == 0)
                        throw;
                }
            }
        }
開發者ID:j-kelly,項目名稱:GalaxiaUniversity-Template,代碼行數:27,代碼來源:Host.cs

示例11: InitializeWebDriver

		private static void InitializeWebDriver() {
			switch (Configuration.BrowserType) {
				case BrowserType.Firefox:
					WebDriver = new FirefoxDriver();
					break;
				case BrowserType.InternetExplorer:
					var ieOptions = new InternetExplorerOptions {
						EnableNativeEvents = true,
						EnablePersistentHover = true,
						EnsureCleanSession = true,
						UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss
					};

					WebDriver = new InternetExplorerDriver("./", ieOptions);
					break;
				case BrowserType.Chrome:
					var chromeOptions = new ChromeOptions();
					chromeOptions.AddArguments("test-type");

					WebDriver = new ChromeDriver("./", chromeOptions);
					break;
				default:
					throw new ArgumentException("Unknown browser type is specified!");
			}

			WebDriver.Manage().Window.Maximize();
			WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Configuration.ImplicitWaitTime));
		}
開發者ID:yizeng,項目名稱:AutomateXeroRepeatingInvoicesTab,代碼行數:28,代碼來源:TestsBase.cs

示例12: StartDriver

		public static IWebDriver StartDriver (string browserType)
		{
			Trace.WriteLine("Start browser: '" + browserType + "'");

			IWebDriver driver = null;
			switch (browserType)
			{
				case "ie":
					{
						driver = new InternetExplorerDriver("Drivers");
						break;
					}
				case "firefox":
					{
						FirefoxProfile firefoxProfile = new FirefoxProfile();
						firefoxProfile.EnableNativeEvents = true;
						firefoxProfile.AcceptUntrustedCertificates = true;

						driver = new FirefoxDriver(firefoxProfile);
						break;
					}
				case "chrome":
					{
						ChromeOptions chromeOptions = new ChromeOptions();
						chromeOptions.AddArgument("--disable-keep-alive");

						driver = new ChromeDriver("Drivers", chromeOptions);
						break;
					}
			}

			driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
			driver.Manage().Window.Maximize();
			return driver;
		}
開發者ID:rrsc,項目名稱:Dnn.Platform,代碼行數:35,代碼來源:TestBase.cs

示例13: GetDriver

        public static IWebDriver GetDriver(DriverType typeOfDriver)
        {
            IWebDriver browser;
            switch (typeOfDriver)
            {
                // NOTE REMOTE DRIVER IS NOT SUPPORTED
                case DriverType.Chrome:
                    ChromeOptions co = new ChromeOptions();
                    browser = new ChromeDriver();
                    break;
                case DriverType.IE:
                    InternetExplorerOptions ieo = new InternetExplorerOptions();
                    browser = new InternetExplorerDriver();
                    break;
                case DriverType.Firefox:    
                default:
                    FirefoxProfile ffp = new FirefoxProfile();
                    ffp.AcceptUntrustedCertificates = true;
                    ffp.Port = 8181;

                    browser = new FirefoxDriver(ffp);
                    break;
            }
            return browser;
        }
開發者ID:kamcio,項目名稱:NSeleniumTestRunner,代碼行數:25,代碼來源:WebDriverFactory.cs

示例14: GetChromeOptions

 private static ChromeOptions GetChromeOptions()
 {
     var option = new ChromeOptions();
     option.AddArgument("start-maximized");
     option.AddExtension(@"C:\downloads\GoogleAnalytics.crx");
     option.Proxy = null;
     return option;
 }
開發者ID:rahulrathore44,項目名稱:OutreachWebdriver,代碼行數:8,代碼來源:InitializeWebDriver.cs

示例15: GetChromeOptions

        private static ChromeOptions GetChromeOptions()
        {
            ChromeOptions option = new ChromeOptions();
            option.AddArgument("start-maximized");

            // option.AddExtension(@"C:\Users\rahul.rathore\Desktop\Cucumber\extension_3_0_12.crx");
            return option;
        }
開發者ID:Saltorel,項目名稱:BDD-CSharp,代碼行數:8,代碼來源:BaseClass.cs


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