当前位置: 首页>>代码示例>>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;未经允许,请勿转载。