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


C# ChromeOptions.AddExtension方法代码示例

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


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

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

示例2: NaverCrawler

        public NaverCrawler()
        {
            string id = ConfigurationManager.AppSettings["id"];
            string password = ConfigurationManager.AppSettings["password"];
            var processList = Process.GetProcessesByName("chromedriver");
            foreach( var process in processList )
            {
                process.Kill();
            }

            var chromeDriverService = ChromeDriverService.CreateDefaultService();
            chromeDriverService.HideCommandPromptWindow = true;

            var option = new ChromeOptions();
            option.AddExtension("3.7_0.crx");
            driver = new ChromeDriver(chromeDriverService, option );

            while (driver.WindowHandles.Count < 2)
            {
                Thread.Sleep(100);
            }

            driver.SwitchTo().Window(driver.WindowHandles[1]);

            WebDriverWait _wait = new WebDriverWait(driver, new TimeSpan(0, 1, 0));

            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 10));

            _wait.Until(d => d.FindElement(By.Id("user_email")));
            driver.FindElementById("user_email").SendKeys(String.Format("{0}@naver.com\n", id));
            _wait.Until(d => d.FindElement(By.Id("user_password")));
            driver.FindElementById("user_password").SendKeys(password);
            driver.FindElementById("loginbtn").Click();

            driver.SwitchTo().Window(driver.WindowHandles[0]);
            driver.Url = loginFormUrl;
            driver.FindElementByCssSelector("#id").SendKeys(id);
            driver.FindElementByCssSelector("#pw").SendKeys(password);

            driver.FindElementByCssSelector("input.int_jogin").Click();

            cookieContainer = new CookieContainer();
            ReadOnlyCollection<OpenQA.Selenium.Cookie> cookieCollections = null;

            bool sessionFound = false;
            while (!sessionFound)
            {
                cookieCollections = driver.Manage().Cookies.AllCookies;
                foreach( var cookie in cookieCollections )
                {
                    if ( cookie.Name == "JSESSIONID" )
                    {
                        sessionFound = true;
                        break;
                    }
                }
            }
            foreach( var cookie in cookieCollections )
            {
                cookieContainer.Add(new System.Net.Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain));
            }

            driver.Quit();
        }
开发者ID:hyunjong-lee,项目名称:Mastermind_bluehole,代码行数:64,代码来源:NaverCrawler.cs

示例3: Start

        protected void Start()
        {
            LoadConfiguration();

            ChromeOptions options = new ChromeOptions();
            options.AddExtension(ExtensionLocation);

            if (_isLocal)
            {
               WebDriver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromSeconds(120));
               WebDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
            }
            else
            {
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.SetCapability(ChromeOptions.Capability, options);
                WebDriver = new RemoteWebDriver(new Uri(""), DesiredCapabilities.Chrome(), TimeSpan.FromSeconds(120));
                WebDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
            }

            NgWebDriver = new NgWebDriver(WebDriver);
        }
开发者ID:herki18,项目名称:ACSStarTrek,代码行数:22,代码来源:TFDriver.cs


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