本文整理汇总了C#中OpenQA.Selenium.IE.InternetExplorerDriver类的典型用法代码示例。如果您正苦于以下问题:C# InternetExplorerDriver类的具体用法?C# InternetExplorerDriver怎么用?C# InternetExplorerDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternetExplorerDriver类属于OpenQA.Selenium.IE命名空间,在下文中一共展示了InternetExplorerDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaunchBrowser
/// <summary>
/// Launches the Selenium WebDriver driven browser specified in the Environments.cs file
/// </summary>
public IWebDriver LaunchBrowser(IWebDriver driver)
{
switch(this.environment.browser)
{
case "*firefox":
_ffp = new FirefoxProfile();
_ffp.AcceptUntrustedCertificates = true;
driver = new FirefoxDriver(_ffp);
break;
case "*iexplore":
driver = new InternetExplorerDriver();
break;
case "*googlechrome":
driver = new ChromeDriver();
break;
case "Android":
capabilities = new DesiredCapabilities("android", "", null);
capabilities.IsJavaScriptEnabled = true;
driver = new RemoteWebDriver(new Uri(string.Format("http://{0}:{1}/hub", environment.host, environment.port)), capabilities);
break;
case "RemoteWebDriver":
capabilities = DesiredCapabilities.Firefox();
var remoteAddress = new Uri(string.Format("http://{0}:{1}/wd/hub", environment.host, environment.port));
driver = new RemoteWebDriver(remoteAddress, capabilities);
break;
}
return driver;
}
示例2: 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;
}
示例3: Should_page_through_items_in_IE
public void Should_page_through_items_in_IE()
{
IWebDriver ieDriver = new InternetExplorerDriver();
ieDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
ieDriver.Navigate().GoToUrl("http://localhost:1392/");
Login(ieDriver);
ieDriver.FindElement(By.LinkText("Orders")).Click();
for (int i = 0; i < 20; i++)
{
IWebElement nextButton = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));
nextButton.Click();
IWebElement pageCount = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));
int pageNumber = int.Parse(pageCount.GetAttribute("value"));
Assert.AreEqual(i + 2, pageNumber);
}
ieDriver.FindElement(By.Id("LoginStatus1")).Click();
ieDriver.Quit();
}
示例4: 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;
}
}
}
示例5: GetDriver
public static IWebDriver GetDriver(string driver, Devices device)
{
DeviceModel model = Device.Get(device);
IWebDriver webDriver;
switch (driver.ToLower())
{
case "safari":
webDriver = new SafariDriver();
break;
case "chrome":
webDriver = new ChromeDriver();
break;
case "ie":
webDriver = new InternetExplorerDriver();
break;
//case "firefox":
default:
var profile = new FirefoxProfile();
profile.SetPreference("general.useragent.override", model.UserAgent);
webDriver = new FirefoxDriver(profile);
webDriver.Manage().Window.Size = model.ScreenSize;
break;
}
return webDriver;
}
示例6: 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;
}
示例7: logging_in_with_invalid_credentials
public void logging_in_with_invalid_credentials()
{
var capabilities = new DesiredCapabilities();
capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);
var driver = new InternetExplorerDriver(capabilities);
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();
}
}
示例8: Main
static void Main(string[] args)
{
try
{
var stopWatch = Stopwatch.StartNew();
DesiredCapabilities capabilities = new DesiredCapabilities();
var driverService = ChromeDriverService.CreateDefaultService(@"E:\");
driverService.HideCommandPromptWindow = true;
var webDriver = new InternetExplorerDriver();
webDriver.Navigate().GoToUrl("http://www.udebug.com/UVa/10812");
IWebElement inputBox = webDriver.FindElement(By.Id("edit-input-data"));
inputBox.SendKeys("3\n2035415231 1462621774\n1545574401 1640829072\n2057229440 1467906174");
IWebElement submitButton = webDriver.FindElement(By.Id("edit-output"));
submitButton.SendKeys("\n");
submitButton.Click();
string answer = webDriver.PageSource;
int begin = answer.IndexOf("<pre>") + 5;
answer = answer.Substring(begin, answer.IndexOf("</pre>") - begin);
Console.WriteLine(answer);
webDriver.Close();
Console.WriteLine(stopWatch.ElapsedMilliseconds);
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
示例9: 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;
}
示例10: when_logging_in_with_an_invalid_username_and_password
public void when_logging_in_with_an_invalid_username_and_password()
{
var capabilities = new DesiredCapabilities();
capabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);
var driver = new InternetExplorerDriver(capabilities);
try
{
driver.Navigate().GoToUrl("http://localhost:52125/Account/LogOn");
driver.FindElement(By.Name("UserName")).SendKeys("[email protected]");
driver.FindElement(By.Name("Password")).SendKeys("BadPass");
driver.FindElement(By.TagName("form")).Submit();
driver.Url.ShouldEqual("http://localhost:52125/Account/LogOn");
driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain(
"The user name or password provided is incorrect.");
}
finally
{
driver.Close();
}
}
示例11: ConfigureDriver
public static IWebDriver ConfigureDriver(IWebDriver driver, string driverType, string driverPath)
{
switch (driverType)
{
case "ie":
{
driver = new InternetExplorerDriver(driverPath);
driver.Manage().Window.Maximize();
return driver;
}
case "firefox":
{
driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
return driver;
}
case "chrome":
{
driver = new ChromeDriver(driverPath);
driver.Manage().Window.Maximize();
return driver;
}
}
return driver;
}
示例12: CreateWebDriver
public IWebDriver CreateWebDriver()
{
var driver = new InternetExplorerDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
return driver;
}
示例13: Main
static void Main(string[] args)
{
//Create an instance of HTTPWatch Controller
Controller control = new Controller();
//Start IE Driver. IE Driver Server is located in C:\\
IWebDriver driver = new InternetExplorerDriver(@"C:\");
// Set a unique initial page title so that HttpWatch can attach to it
string uniqueTitle = Guid.NewGuid().ToString();
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("document.title = '" + uniqueTitle + "';");
// Attach HttpWatch to the instance of Internet Explorer created through WebDriver
Plugin plugin = control.AttachByTitle(uniqueTitle);
//Open the HTTPWatch Window
plugin.OpenWindow(false);
//Navigate to the BMI Application Page
driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/bmicalculator.html");
//Perform some steps
driver.FindElement(By.Id("heightCMS")).SendKeys("181");
driver.FindElement(By.Id("weightKg")).SendKeys("80");
driver.FindElement(By.Id("Calculate")).Click();
//Export the HAR Log generated to a file
plugin.Log.Save(@"C:\bmicalc.hwl");
//Close the Internet Explorer
driver.Close();
}
示例14: 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;
}
示例15: 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;
}