當前位置: 首頁>>代碼示例>>C#>>正文


C# InternetExplorerDriver.FindElement方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.IE.InternetExplorerDriver.FindElement方法的典型用法代碼示例。如果您正苦於以下問題:C# InternetExplorerDriver.FindElement方法的具體用法?C# InternetExplorerDriver.FindElement怎麽用?C# InternetExplorerDriver.FindElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.IE.InternetExplorerDriver的用法示例。


在下文中一共展示了InternetExplorerDriver.FindElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

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

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

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

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

示例6: crawlPartsbase

        private static void crawlPartsbase()
        {
            IWebDriver driver = new InternetExplorerDriver(@"F:\IEDriverServer_x64_2.46.0");
            driver.Navigate().GoToUrl("http://www.partsbase.com/landing/login.asp");

            var usernameField = driver.FindElement(By.Name("username"));
            usernameField.SendKeys("tallaadmin");

            var passwdField = driver.FindElement(By.Name("password"));
            passwdField.SendKeys("Ta11a2015!");

            var submitBtn = driver.FindElement(By.XPath("//a[@class='btn btn-success' and @value='Log In']"));
            submitBtn.Click();
        }
開發者ID:tracyqi,項目名稱:inventory,代碼行數:14,代碼來源:Program.cs

示例7: CrawlILSmart

        //tallaadmin
        //Ta11a2015!
        private static void CrawlILSmart()
        {
            IWebDriver driver = new InternetExplorerDriver(@"F:\IEDriverServer_x64_2.46.0");
            driver.Navigate().GoToUrl("http://static.ilsmart.com/pages/ILSLogin2014.htm?TabId=56&amp;language=en-US");

            //<iframe src="http://static.ilsmart.com/pages/ILSLogin2014.htm?TabId=56&amp;language=en-US" frameborder="0" style="width: 620px; height: 100px;" scrolling="no"></iframe>
            // <input tabindex="3" class="btn btn-primary btn-sm enter" type="submit" alt="Enter" value="Enter">
            var usernameField = driver.FindElement(By.Name("username"));
            usernameField.SendKeys("c08hu01");

            var passwdField = driver.FindElement(By.Name("password"));
            passwdField.SendKeys("Ta11a2015%");

            var submitBtn = driver.FindElement(By.XPath("//input[@type='submit' and @value='Enter']"));
            submitBtn.Click();
        }
開發者ID:tracyqi,項目名稱:inventory,代碼行數:18,代碼來源:Program.cs

示例8: when_logging_in_with_a_valid_username_and_password

		public void when_logging_in_with_a_valid_username_and_password()
		{
			var options = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true };
			var driver = new InternetExplorerDriver(options);

			try
			{
				driver.Navigate().GoToUrl("http://localhost:52125/Account/LogOn");

				driver.FindElement(By.Name("UserName")).SendKeys("[email protected]");
				driver.FindElement(By.Name("Password")).SendKeys("RealPassword");
				driver.FindElement(By.TagName("form")).Submit();

				driver.Url.ShouldEqual("http://localhost:52125/");
			}
			finally
			{
				driver.Close();
			}
		}
開發者ID:robertsimmons,項目名稱:SpecsFor,代碼行數:20,代碼來源:LoginSpecsWithoutSpecsForMvc.cs

示例9: OpenGoogle

        public void OpenGoogle()
        {
            IWebDriver driver = new InternetExplorerDriver();
            //IWebDriver driver = new FirefoxDriver();

            driver.Navigate().GoToUrl("http://www.google.com/");
            IWebElement query = driver.FindElement(By.Name("q"));
            query.SendKeys("Cheese");
            System.Console.WriteLine("Page title is: " + driver.Title);
            // TODO add wait
            driver.Quit();
        }
開發者ID:vbratsun,項目名稱:CSTutorial,代碼行數:12,代碼來源:Class2.cs

示例10: Main

        static void Main(string[] args)
        {
            IWebDriver driver = new InternetExplorerDriver();

            driver.Navigate().GoToUrl("http://e1.englishtown.com/partner/coolschool/Default.aspx");

            IWebElement userNameQuery = driver.FindElement(By.Name("UserName"));
            IWebElement passwdQuery = driver.FindElement(By.Name("Password"));

            userNameQuery.SendKeys("cliu9800");
            passwdQuery.SendKeys("pass");

            IWebElement submitButton = driver.FindElement(By.Id("loginTrigger"));

            submitButton.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(t => t.PageSource.ToLower().IndexOf("currentcourse") > 0);

            System.Console.WriteLine(string.Format("Page title is: {0}", driver.Title));

            driver.Quit();
        }
開發者ID:Astranagant,項目名稱:WebDriverTest,代碼行數:23,代碼來源:Program.cs

示例11: CanGetTweetsOnDefaultPage

        public void CanGetTweetsOnDefaultPage()
        {
            IWebDriver driver = new InternetExplorerDriver();

            driver.Navigate().GoToUrl("http://localhost:51373/");

            IWebElement button = driver.FindElement(By.Id("btn"));
            button.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until((d) => { return d.FindElement(By.Id("results")); });

            IList<IWebElement> results = driver.FindElements(By.XPath("//ul[@id='results']/li"));
            IList<IWebElement> accounts = driver.FindElements(By.XPath("//div[@id='summary']//tr"));

            //Assert.AreEqual(1, results.Count);
            Assert.IsTrue(results.Count > 0);
            //Assert.AreEqual(1, accounts.Count);
            Assert.IsTrue(accounts.Count > 1);

            // Close the browser
            //driver.Quit();
        }
開發者ID:mathewvance,項目名稱:MathewVanceVerrusTechnicalAssignment,代碼行數:23,代碼來源:BrowserTest.cs

示例12: AppDetail

 public AppDetail(InternetExplorerDriver ieDriver)
 {
     ProperyNames = new List<string>();
     Properties = new List<string>();
     var table = ieDriver.FindElement(By.ClassName("ms-formtable"));
     var rows = table.FindElements(By.TagName("tr"));
     foreach (var row in rows)
     {
         var cells = row.FindElements(By.TagName("td"));
         var propName = cells[0].Text;
         var links = cells[1].FindElements(By.TagName("a"));
         var prop = cells[1].Text;
         for (var i = 0; i < links.Count; i++)
         {
             var href = links[i].GetAttribute("href");
             if(!href.Contains(Program.Domian))
                 continue;
             prop = prop.Replace(links[i].Text,
                 "||(|)||" + href + "||()||" + links[i].Text + "||(|)||");
         }
         ProperyNames.Add(propName);
         Properties.Add(prop);
     }
 }
開發者ID:moverperfect,項目名稱:Extract-From-Sharepoint,代碼行數:24,代碼來源:AppDetail.cs

示例13: logging_in_with_no_credentials_displays_validation_error

        public void logging_in_with_no_credentials_displays_validation_error()
        {
            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.TagName("form")).Submit();

                driver.Url.ShouldEqual(TargetAppUrl + "/LogOn");

                driver.FindElements(By.CssSelector("span.field-validation-error[data-valmsg-for=\"EmailAddress\"]")).ShouldNotBeEmpty();
                driver.FindElements(By.CssSelector("span.field-validation-error[data-valmsg-for=\"Password\"]")).ShouldNotBeEmpty();
            }
            finally
            {
                driver.Close();
            }
        }
開發者ID:williamflock,項目名稱:Fail-Tracker,代碼行數:24,代碼來源:AuthenticationSpecs.cs

示例14: Test_for_donation_error_text

        public void Test_for_donation_error_text()
        {
            RemoteWebDriver Driver = new InternetExplorerDriver();
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");

            // On Main Page
            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title='Support us']");
            lnkSupportUs.Click();

            // On Make your donation page

            var radio50UAH = Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();


            // And clich on "Donate" button
            var btnDonate = Driver.FindElementByCssSelector(@"input[value='Donate by credit/debit card']");
            btnDonate.Click();


            // On Billing information

            var txtFirstName = Driver.FindElementByName("fname");
            var txtLastName = Driver.FindElementByName("lname");
            var txtStreet = Driver.FindElementByName("street");
            var txtPostalCode = Driver.FindElementByName("zip");
            var txtCity = Driver.FindElementByName("city");
            var txtEmailAddress = Driver.FindElementByName("emailAdd");

            var radioCardType = Driver.FindElementByCssSelector(@"input[name='cardtype'][value='visa']");


            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtLastName.Clear();
            txtLastName.SendKeys("Poopkin");

            txtCity.Clear();
            txtCity.SendKeys("Kyiv");

            txtEmailAddress.Clear();
            txtEmailAddress.SendKeys("[email protected]");

            txtPostalCode.Clear();
            txtPostalCode.SendKeys("80999");

            txtStreet.Clear();
            txtStreet.SendKeys("It is very boring");

            radioCardType.Click();


            // Donation form second part

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(30));

            string frameSelector = @"div#payment > iframe";

            wait.Until(ExpectedConditions.ElementExists(By.CssSelector(frameSelector)));

            var frameFormSecondPart = Driver.FindElementByCssSelector(frameSelector);

            Driver.SwitchTo().Frame(frameFormSecondPart);

            string cardNumSelector = @"CREDITCARDNUMBER";
            wait.Until(ExpectedConditions.ElementIsVisible(By.Name(cardNumSelector)));

            var txtCreditCardNum = Driver.FindElementByName(cardNumSelector);
            var selectExpMonth = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementByName(@"EXPIRYDATE_YY"));
            var txtCVV = Driver.FindElementByName(@"CVV");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("4716699955349929");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("555");

            // Looks like we cannot click on this button. 
            // Well... 
            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate result page

            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(@"div#mw-content-text * big > span")));
            var lblTransactionErrorMessage = Driver.FindElement(By.CssSelector(@"div#mw-content-text * big > span"));

            Assert.AreEqual("Your transaction could not be accepted.", lblTransactionErrorMessage.Text);

            Driver.Dispose();

        }
開發者ID:qaleader,項目名稱:MyPresentations.Slides-n-Source,代碼行數:99,代碼來源:UnitTest1.cs

示例15: TestMethod1

        public void TestMethod1()
        {
            //RemoteWebDriver Driver = new InternetExplorerDriver();
            RemoteWebDriver Driver = new InternetExplorerDriver();
            //Driver.Url = "www.football.ua";
            Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");
            //Driver.Manage().Window.Maximize();

            var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title = 'Support us']");
            lnkSupportUs.Click();

            // Cannot find with this locator!
            var radio50UAH = Driver.FindElementByXPath("/html/body/div[3]/div[2]/div[3]/table/tbody/tr/td[2]/form/div/div[3]/table/tbody/tr[1]/td[1]/label");//Driver.FindElementById("input_amount_0");// Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
            radio50UAH.Click();

            var btnDonate = Driver.FindElement(By.ClassName("payment-method-button"));
            btnDonate.Click();

            var txtFirstName = Driver.FindElementById("fname");
            var txtlastName = Driver.FindElementById("lname");
            var txtEmail = Driver.FindElementById("emailAdd");
            var radioCardType = Driver.FindElementById("cc-visa");

            txtFirstName.Clear();
            txtFirstName.SendKeys("Vasya");

            txtlastName.Clear();
            txtlastName.SendKeys("Poopkin");

            txtEmail.Clear();
            txtEmail.SendKeys("[email protected]");

            radioCardType.Click();

            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(6));

            var txtCreditCardNum = Driver.FindElementByName("CREDITCARDNU");
            var selectExpMonth = new SelectElement(Driver.FindElementById("F1010_MM"));
            var selectExpYear = new SelectElement(Driver.FindElementById("F1010_YY"));
            var txtCVV = Driver.FindElementById(@"F1136");
            var btnSubmit = Driver.FindElementById(@"btnSubmit");

            txtCreditCardNum.Clear();
            txtCreditCardNum.SendKeys("8975397698238467");

            selectExpMonth.SelectByText("02");
            selectExpYear.SelectByText("15");

            txtCVV.Clear();
            txtCVV.SendKeys("836");

            btnSubmit.SendKeys(Keys.Enter);

            Driver.SwitchTo().DefaultContent();

            // On Donate results page

            string headerSelector = @"h1.firstHeading";
            var headingElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(headerSelector)));

            Assert.AreEqual("Donate-error", headingElement.Text);

            Driver.Quit();
            Driver.Dispose();
        }
開發者ID:thebestsoftware,項目名稱:testsautomationpractice,代碼行數:65,代碼來源:UnitTest1.cs


注:本文中的OpenQA.Selenium.IE.InternetExplorerDriver.FindElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。