本文整理汇总了C#中OpenQA.Selenium.IE.InternetExplorerOptions类的典型用法代码示例。如果您正苦于以下问题:C# InternetExplorerOptions类的具体用法?C# InternetExplorerOptions怎么用?C# InternetExplorerOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternetExplorerOptions类属于OpenQA.Selenium.IE命名空间,在下文中一共展示了InternetExplorerOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FakeIEDriver
public FakeIEDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options)
{
Console.WriteLine("dir opt2");
this.UnitTestReport =
//IEDriverConstructorOptions.ie_with_path_and_options.ToString();
DriverServerConstructorOptions.with_path_and_options.ToString();
}
示例2: GetDriver
//Start the browser depending on the setting
public void GetDriver(WebBrowsers webBrws)
{
WebBrws = webBrws;
if (webBrws == WebBrowsers.Ie)
{
//Secutiry setting for IE
var capabilitiesInternet = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true };
Driver = new InternetExplorerDriver(capabilitiesInternet);
}
else
if (webBrws == WebBrowsers.FireFox)
{
//FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
FirefoxProfile profile = new FirefoxProfile();
// profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
Driver = new FirefoxDriver(profile);
}
else
if (webBrws == WebBrowsers.Chrome)
{
//Chrome driver requires the ChromeDriver.exe
Driver = new ChromeDriver(@"..\..\..\lib\BrowserDriver\Chrome");
}
else { throw new WebDriverException(); }
Selenium = new WebDriverBackedSelenium(Driver, BaseUrl);
}
示例3: logging_in_with_invalid_credentials
public void logging_in_with_invalid_credentials()
{
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
var driver = new InternetExplorerDriver(options);
driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff");
try
{
driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn");
driver.FindElement(By.Name("EmailAddress")).SendKeys("[email protected]");
driver.FindElement(By.Name("Password")).SendKeys("BadPass");
driver.FindElement(By.TagName("form")).Submit();
driver.Url.ShouldEqual(TargetAppUrl + "/LogOn");
driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
"The user name or password provided is incorrect.");
}
finally
{
driver.Close();
}
}
示例4: PerformInitialize
/// <summary>
/// Performs the initialize of the browser.
/// </summary>
/// <param name="driverFolder">The driver folder.</param>
/// <param name="proxy">The proxy.</param>
/// <returns>
/// The web driver.
/// </returns>
protected override IWebDriver PerformInitialize(string driverFolder, Proxy proxy)
{
var options = new InternetExplorerOptions();
options.Proxy = proxy;
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
return new InternetExplorerDriver(driverFolder, options);
}
示例5: GetConfigBrowser
public static IWebDriver GetConfigBrowser(string browserName)
{
string AppRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string strDriverPath = null;
IWebDriver webDriver = null;
if (browserName.Equals("Firefox", StringComparison.InvariantCultureIgnoreCase))
{
webDriver = new FirefoxDriver();
}
else if (browserName.Equals("chrome", StringComparison.InvariantCultureIgnoreCase))
{
strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\chromedriver_win32");
webDriver = new ChromeDriver(strDriverPath);
}
else if (browserName.Equals("IE", StringComparison.InvariantCultureIgnoreCase))
{
InternetExplorerOptions options = new InternetExplorerOptions()
{
EnableNativeEvents = true,
IgnoreZoomLevel = true
};
strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\IEDriverServer_Win32_2.44.0");
webDriver = new InternetExplorerDriver(strDriverPath, options, TimeSpan.FromMinutes(3.0));
}
if (webDriver == null)
throw new Exception("must configure browsername in aap.config");
else
return webDriver;
}
示例6: SetupDriver
/// <summary>
/// Creates a driver if it has not been created yet.
/// </summary>
public void SetupDriver()
{
if (_driver == null)
{
switch (DriverType)
{
case DriverTypes.Phantom:
_driver = new PhantomJSDriver(DriversPath);
break;
case DriverTypes.Firefox:
_driver = new FirefoxDriver();
break;
case DriverTypes.InternetExplorer:
var options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
_driver = new InternetExplorerDriver(DriversPath, options);
break;
case DriverTypes.Chrome:
default:
if (!File.Exists("chromedriver.exe"))
{
_driver = new ChromeDriver(DriversPath);
}
else
_driver = new ChromeDriver();
break;
}
}
}
示例7: InitDriver
public void InitDriver()
{
if (!Directory.Exists(@"P:\LabsDeploymentItems")) throw new Exception(@"Unable to locate P:\LabsDeploymentItems");
switch (Properties.Settings.Default.BROWSER)
{
case BrowserType.Chrome:
WebDriver = new ChromeDriver(driversLocation);
break;
case BrowserType.Ie:
InternetExplorerOptions opts = new InternetExplorerOptions();
opts.EnsureCleanSession = true;
opts.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
WebDriver = new InternetExplorerDriver(driversLocation, opts);
break;
case BrowserType.Firefox:
WebDriver = new FirefoxDriver();
break;
default:
throw new ArgumentException("Invalid BROWSER Setting has been used");
}
WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Properties.Settings.Default.IMPLICIT_WAIT_SECONDS));
WebDriver.Manage().Window.Maximize();
}
示例8: Start
/// <summary>
/// Starts the specified browser.
/// </summary>
/// <param name="browser">The browser.</param>
/// <exception cref="System.NotSupportedException">When driver not supported</exception>
public void Start(string browser)
{
switch (browser)
{
case "Firefox":
Handle = new FirefoxDriver(this.FirefoxProfile);
break;
case "FirefoxPortable":
var profile = this.FirefoxProfile;
var firefoxBinary = new FirefoxBinary(BaseConfiguration.FirefoxPath);
Handle = new FirefoxDriver(firefoxBinary, profile);
break;
case "InternetExplorer":
var options = new InternetExplorerOptions
{
EnsureCleanSession = true,
};
Handle = new InternetExplorerDriver(@"Drivers\", options);
break;
case "Chrome":
Handle = new ChromeDriver(@"Drivers\");
break;
default:
throw new NotSupportedException(
string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", browser));
}
Handle.Manage().Window.Maximize();
}
示例9: CreateWebDriver
private static IWebDriver CreateWebDriver()
{
IWebDriver driver = null;
var type = ConfigurationManager.AppSettings["WebDriver"];
switch (type)
{
case "Firefox":
{
var profile = new FirefoxProfile
{
AcceptUntrustedCertificates = true,
EnableNativeEvents = true
};
driver = new FirefoxDriver(profile);
break;
}
case "InternetExplorer":
{
// Currently not working
var options = new InternetExplorerOptions
{
IgnoreZoomLevel = true
};
driver = new InternetExplorerDriver(options);
break;
}
case "Chrome":
default:
throw new NotSupportedException();
}
return driver;
}
示例10: GetLocalDriver
/// <summary>
/// ‘абричный метод
/// </summary>
/// <param name="browser"></param>
/// <returns></returns>
public static RemoteWebDriver GetLocalDriver(string browser)
{
InternetExplorerOptions internetExplorerOptions;
switch (browser)
{
case "Chrome":
return new ChromeDriver(PathToDriver);
case "Firefox":
var profile = new FirefoxProfile();
//profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", ConfigurationManager.AppSettings["SiteIP"]);
return new FirefoxDriver(profile);
case "IE":
internetExplorerOptions = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = true
};
return new InternetExplorerDriver(
PathToDriver,
internetExplorerOptions);
default:
internetExplorerOptions = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = true
};
return new InternetExplorerDriver(
PathToDriver,
internetExplorerOptions);
}
}
示例11: Create
public static IWebDriver Create(string browser)
{
DesiredCapabilities capabilities;
IWebDriver driver;
switch (browser) {
case "chrome":
capabilities = DesiredCapabilities.Chrome();
driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
break;
case "internet explorer":
InternetExplorerOptions options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
capabilities = (DesiredCapabilities)options.ToCapabilities();
driver = new RemoteWebDriver(remoteWebDriverUri, capabilities, TimeSpan.FromSeconds(10));
break;
case "edge":
capabilities = DesiredCapabilities.Edge();
driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
break;
default:
capabilities = DesiredCapabilities.Firefox();
driver = new RemoteWebDriver(remoteWebDriverUri, capabilities);
break;
}
return driver;
}
示例12: 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;
}
示例13: Create
public IWebDriver Create(LocalDriverConfiguration configuration)
{
switch (configuration.Browser)
{
case "chrome":
_driver = new ChromeDriver(@"DriverServices");
break;
case "internet explorer":
var options = new InternetExplorerOptions { EnableNativeEvents = false };
_driver = new InternetExplorerDriver(@"DriverServices", options);
break;
case "firefox":
_driver = new FirefoxDriver();
break;
case "phantomjs":
_driver = new PhantomJSDriver(@"DriverServices");
break;
default:
_driver = new FirefoxDriver();
break;
}
return _driver;
}
示例14: Driver
/// <summary>
/// Initializes a new instance of the <see cref="Driver"/> class.
/// </summary>
/// <param name="browser">Browser name.</param>
/// <param name="timeout">Implicit time to wait.</param>
public Driver(string browser, int timeout = 10)
{
this.timeout = timeout;
Log.Debug("Working directory: " + this.directory);
Log.Debug("Browser: " + browser);
Log.Debug("Driver timeout: " + timeout);
switch (browser)
{
case "firefox":
this.driver = new FirefoxDriver();
break;
case "ie":
var ieOptions = new InternetExplorerOptions { EnsureCleanSession = true };
this.driver = new InternetExplorerDriver(this.directory, ieOptions);
break;
case "edge":
this.driver = new EdgeDriver(this.directory);
break;
case "chrome":
this.driver = new ChromeDriver(this.directory);
break;
case "safari":
this.driver = new SafariDriver();
break;
default:
throw new Exception("Browser name is incorrect.");
}
this.driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, timeout));
this.driver.Manage().Cookies.DeleteAllCookies();
this.driver.Manage().Window.Maximize();
}
示例15: NewWebDriver
public IWebDriver NewWebDriver(Browser browser)
{
if (browser == Browser.Firefox)
return new FirefoxDriver();
if (browser == Browser.InternetExplorer)
{
var options = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = true
};
return new InternetExplorerDriver(options);
}
if (browser == Browser.Chrome)
return new ChromeDriver();
if (browser == Browser.Android)
return new AndroidDriver();
if (browser == Browser.HtmlUnit)
return new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
if (browser == Browser.HtmlUnitWithJavaScript) {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.HtmlUnit();
desiredCapabilities.IsJavaScriptEnabled = true;
return new RemoteWebDriver(desiredCapabilities);
}
if (browser == Browser.PhantomJS)
return new PhantomJSDriver();
return browserNotSupported(browser,null);
}