本文整理汇总了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;
}
示例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();
}
示例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);
}