当前位置: 首页>>代码示例>>C#>>正文


C# ChromeOptions.AddArguments方法代码示例

本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeOptions.AddArguments方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeOptions.AddArguments方法的具体用法?C# ChromeOptions.AddArguments怎么用?C# ChromeOptions.AddArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenQA.Selenium.Chrome.ChromeOptions的用法示例。


在下文中一共展示了ChromeOptions.AddArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: CreateChromeGridDriver

        public static IWebDriver CreateChromeGridDriver(string profileName, string hubAddress)
        {
            if (hubAddress == null)
            {
                throw new ArgumentException("remoteAddress");
            }

            var chromeOptions = new ChromeOptions();
            if (!string.IsNullOrWhiteSpace(profileName))
            {
                var fileChars = Path.GetInvalidFileNameChars();
                var pathChars = Path.GetInvalidFileNameChars();
                var invalidChars = fileChars.Union(pathChars);

                profileName = String.Join("", profileName.Where(c => !invalidChars.Contains(c)));

                chromeOptions.AddArguments(String.Format("user-data-dir=c:\\ChromeProfiles\\{0}", profileName));
            }

            RemoteWebDriver Driver = new RemoteWebDriver(new Uri(hubAddress), chromeOptions.ToCapabilities());

            Driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 1, 0));
            Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 1));
            Driver.Manage().Window.Maximize();
            return Driver;
        }
开发者ID:chriscore,项目名称:SpecDriver,代码行数:26,代码来源:WebDriver.cs

示例3: ChatGeneratorClass

 //private const int volumizingCounter = 100;
 public ChatGeneratorClass()
 {
     ChromeOptions options = new ChromeOptions();
     options.AddArguments("--incognito");
     options.AddArguments("--start-minimized");
     driver = new ChromeDriver(options);
     baseUrl = "http://pofig.livetex.ru/";
 }
开发者ID:PirateOfTheNeverland,项目名称:ChatGenerator,代码行数:9,代码来源:ChatGeneratorClass.cs

示例4: 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

示例5: 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

示例6: 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

示例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: tstObject

        public tstObject(int typNum)
        {
            brwsrType = typNum;

            switch (typNum)
            {
                //create a Chrome object
                case 1:
                {
                    var options = new ChromeOptions();

                    //set the startup options to start maximzed
                    options.AddArguments("start-maximized");

                    //start Chrome maximized
                    driver = new ChromeDriver(@Application.StartupPath, options);

                    //Wait 10 seconds for an item to appear
                    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));
                    break;
                }

                //create an IE object
                case 2:
                {
                    //var options = new InternetExplorerOptions();

                    //set the startup options to start maximzed
                    //options.ToCapabilities();

                    driver = new InternetExplorerDriver(@Application.StartupPath);

                    //maximize window
                    driver.Manage().Window.Maximize();

                    //Wait 4 seconds for an item to appear
                    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));

                    break;
                }
                default:
                {
                    FirefoxProfile profile = new FirefoxProfile();
                    profile.SetPreference("webdriver.firefox.profile", "cbufsusm.default");
                    profile.AcceptUntrustedCertificates = true;

                    driver = new FirefoxDriver(profile); //profile

                    //maximize window
                    driver.Manage().Window.Maximize();

                    //Wait 4 seconds for an item to appear
                    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));
                    break;
                }
            }
        }
开发者ID:modulexcite,项目名称:StudentSuccessDashboard,代码行数:57,代码来源:Test_Functions.cs

示例9: TestConsole

        static TestConsole()
        {
            var chromeOptions = new ChromeOptions();
            chromeOptions.AddArguments("--disable-web-security");
            chromeOptions.AddArguments("--start-maximized");
            WebDriver = new ChromeDriver(chromeOptions);


            //WebDriver = new InternetExplorerDriver(new InternetExplorerOptions()
            //    {
            //        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
            //        UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Ignore
            //    });
            WebDriver.Manage().Window.Maximize();
            WebDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(VeryLongWait8));
           
         

        }
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:19,代码来源:TestConsole.cs

示例10: StartDriver

        public void StartDriver()
        {
            var chromeOptions = new ChromeOptions();
            chromeOptions.AddArguments("--start-maximized");
            switch (_browserName)
            {
                case BrowserNames.Chrome:

                    if (!_isUsingGrid)
                    {
                        _driver = new ChromeDriver(WebDriversDirectory, chromeOptions);
                    }
                    else
                    {
                        _capability.SetCapability(ChromeOptions.Capability, chromeOptions);
                    }
                    break;
                case BrowserNames.Firefox:
                    if (!_isUsingGrid)
                    {
                        _driver = new FirefoxDriver(new FirefoxProfile{EnableNativeEvents = true});
                        _driver.Manage().Window.Maximize();
                    }
                    break;
                case BrowserNames.InternetExplorer:
                    if (!_isUsingGrid)
                    {
                        var internetExplorerOptions = new InternetExplorerOptions
                        {
                            EnableNativeEvents = true
                        };
                        _driver = new InternetExplorerDriver(WebDriversDirectory,internetExplorerOptions);
                        _driver.Manage().Window.Maximize();
                    }
                    break;
                case BrowserNames.Safari:
                    if (!_isUsingGrid)
                    {
                        _driver = new SafariDriver();
                        _driver.Manage().Window.Maximize();
                    }
                    break;
                default:
                    throw new NotSupportedException("Unsupported browser.");
            }
            if (_isUsingGrid)
            {
                _capability.IsJavaScriptEnabled = true;
                _driver = new ExtendedRemoteWebDriver(new Uri(Configuration.HubUrl), _capability);
                _driver.Manage().Window.Maximize();
            }
            SetImplicitWait(Configuration.ImplicitWait);
        }
开发者ID:sadeghsm,项目名称:ChronoZoom,代码行数:53,代码来源:Environment.cs

示例11: CreateLocalDriver

 public override IWebDriver CreateLocalDriver()
 {
     DriverType = WebDriverType.Chrome;
     var driverService = ChromeDriverService.CreateDefaultService();
     driverService.EnableVerboseLogging = true;
     driverService.HideCommandPromptWindow = true;
     var chromeOptions = new ChromeOptions();
     var capabilities = DesiredCapabilities.Chrome();
     chromeOptions.AddArguments(new string[] { "test-type" });
     capabilities.SetCapability(ChromeOptions.Capability, chromeOptions);
     return new ChromeDriver(driverService, chromeOptions);
 }
开发者ID:IIITanbI,项目名称:2,代码行数:12,代码来源:ChromeWebDriverConfig.cs

示例12: Login

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

            //var ieoptions = new InternetExplorerOptions();
            //DesiredCapabilities iecapabilities = DesiredCapabilities.InternetExplorer();
            //iecapabilities.SetCapability("internetexplorer.switches", (object)("--start-maxisized"));
            //ieoptions.AddAdditionalCapability("--test-type", "--start-maximized");
            //ieoptions.AddAdditionalCapability("--test-type", "--ignore-certificate-errors");
            //var iedriver = new InternetExplorerDriver(@"C:\Program Files (x86)\Internet Explorer");

            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,代码行数:38,代码来源:Locator.cs

示例13: CreateChromeOptions

        private static ChromeOptions CreateChromeOptions(bool leaveBrowserRunning)
        {
            try
            {
                var options = new ChromeOptions
                {
                    LeaveBrowserRunning = leaveBrowserRunning
                };

                options.AddArguments("start-maximized");

                return options;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:unclefil,项目名称:Blackbox-Testing-Automation,代码行数:18,代码来源:DriverCreator.cs

示例14: ScenarioBase

        public ScenarioBase()
        {
            Debug.Listeners.Add(new DefaultTraceListener());
            var browser = "Chrome";

            if (browser == "Chrome")
            {
                ChromeOptions options = new ChromeOptions();
                options.AddArguments("chrome.switches", "--disable-extensions");

                ActorBase.I = new ChromeDriver(options);
                var opts = ActorBase.I.Manage();
                opts.Window.Maximize();
            }
            else if (browser == "IE")
            {
                ActorBase.I = new InternetExplorerDriver();
                var opts = ActorBase.I.Manage();
                opts.Window.Maximize();
            }
            else if (browser == "Firefox")
            {
                ActorBase.I = new FirefoxDriver();
                var opts = ActorBase.I.Manage();
                opts.Window.Maximize();
            }

            else if (browser == "Safari")
            {
                ActorBase.I = new SafariDriver();
                var opts = ActorBase.I.Manage();
                opts.Window.Maximize();
            }
            else if (browser == "PhantomJS")
            {
                var driverService = PhantomJSDriverService.CreateDefaultService();
                driverService.HideCommandPromptWindow = true;

                ActorBase.I = new PhantomJSDriver(driverService);
                var opts = ActorBase.I.Manage();
                opts.Window.Maximize();
            }
        }
开发者ID:tablesmit,项目名称:Selenium-Webdriver-helpers,代码行数:43,代码来源:ScenarioBase.cs

示例15: CreateChromeDriver

        public static IWebDriver CreateChromeDriver(string profileName, string path = null)
        {
            var chromeOptions = new ChromeOptions();
            if (!string.IsNullOrWhiteSpace(profileName))
            {
                var fileChars = Path.GetInvalidFileNameChars();
                var pathChars = Path.GetInvalidFileNameChars();
                var invalidChars = fileChars.Union(pathChars);

                profileName = String.Join("", profileName.Where(c => !invalidChars.Contains(c)));

                chromeOptions.AddArguments(String.Format("user-data-dir=c:\\ChromeProfiles\\{0}", profileName));
            }

            ChromeDriver Driver;

            if (!string.IsNullOrWhiteSpace(path))
            {
                //var service = ChromeDriverService.CreateDefaultService(path);
                //service.EnableVerboseLogging = true;
                //service.LogPath = "chromedriver.log";
                Driver = new ChromeDriver(path, chromeOptions);
            }
            else
            {
                //var service = ChromeDriverService.CreateDefaultService();
                //service.EnableVerboseLogging = true;
                //service.LogPath = "chromedriver.log";
                Driver = new ChromeDriver(chromeOptions);
            }

            Driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 1, 0));
            Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 1));
            Driver.Manage().Window.Maximize();
            return Driver;
        }
开发者ID:chriscore,项目名称:SpecDriver,代码行数:36,代码来源:WebDriver.cs


注:本文中的OpenQA.Selenium.Chrome.ChromeOptions.AddArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。