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


C# IE.InternetExplorerDriver类代码示例

本文整理汇总了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;
        }
开发者ID:tmacblane,项目名称:TestManager,代码行数:32,代码来源:WebBrowser.cs

示例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;
        }
开发者ID:wpdiary,项目名称:PolyGlotPersistence,代码行数:30,代码来源:BrowserSelect.cs

示例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();
        }
开发者ID:NathanGloyn,项目名称:Selenium-UI-Testing,代码行数:25,代码来源:When_using_other_browsers.cs

示例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;
                }
            }

        }
开发者ID:J4S0Nc,项目名称:Useful.Utilities,代码行数:34,代码来源:WebDriver.cs

示例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;
 }
开发者ID:maartenkuijpers,项目名称:SeleniumTemplate,代码行数:25,代码来源:SeleniumDriverHelper.cs

示例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;
		}
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:35,代码来源:TestBase.cs

示例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();
            }
        }
开发者ID:williamflock,项目名称:Fail-Tracker,代码行数:26,代码来源:AuthenticationSpecs.cs

示例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);
     }
 }
开发者ID:HuyTranQ,项目名称:UvaLocalJudge,代码行数:27,代码来源:Program.cs

示例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;
        }
开发者ID:kamcio,项目名称:NSeleniumTestRunner,代码行数:25,代码来源:WebDriverFactory.cs

示例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();
            }
        }
开发者ID:rajeshpillai,项目名称:SpecsFor,代码行数:25,代码来源:LoginSpecsWithoutSpecsForMvc.cs

示例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;
 }
开发者ID:marcinkoczan,项目名称:selenium,代码行数:25,代码来源:SelMetody.cs

示例12: CreateWebDriver

 public IWebDriver CreateWebDriver()
 {
     var driver = new InternetExplorerDriver();
     driver.Manage().Window.Maximize();
     driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
     return driver;
 }
开发者ID:xcyroo,项目名称:InnovationDay.AcceptanceTesting,代码行数:7,代码来源:LocalIeEnvironment.cs

示例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();
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:33,代码来源:Program.cs

示例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;
        }
开发者ID:sergiofagostinho,项目名称:netponto.specflow,代码行数:35,代码来源:WebDriverHelper.cs

示例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;
		}
开发者ID:florianwittmann,项目名称:regtesting,代码行数:34,代码来源:LocalWebDriverFactory.cs


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