public FindElements ( By by ) : ReadOnlyCollection |
||
by | By | By mechanism for finding the element. |
return | ReadOnlyCollection |
public void CanGetTweetsOnDefaultPage() { IWebDriver driver = new InternetExplorerDriver(); driver.Navigate().GoToUrl("http://*****:*****@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(); }
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(); } }
static void Main(string[] args) { GetUserInfo(); // Create a new IE driver and navigate to the url var ieDriver = new InternetExplorerDriver(); ieDriver.Navigate().GoToUrl(_listUrl); // Wait for the user to log in and go through security concerns Console.WriteLine("Please log in to the sharepoint site and wait for it to load, once complete please press enter"); Console.ReadLine(); var mainStopwatch = new Stopwatch(); mainStopwatch.Start(); Console.WriteLine("Looking at the site"); // Retreive all of the rows var all = ieDriver.FindElements(By.ClassName("ms-itmhover")); Console.WriteLine("Found " + all.Count + " applications in " + mainStopwatch.ElapsedMilliseconds + " milliseconds"); mainStopwatch.Restart(); // Grab all of the links to the apps var allLinks = new string[all.Count]; var i = 0; foreach (IWebElement element in all) { allLinks[i] = element.FindElement(By.ClassName("ms-vb-title")).FindElement(By.TagName("a")).GetAttribute("href"); i++; Console.WriteLine(i + "/" + all.Count + " Item urls discovered"); } Console.WriteLine("All items urls discovered in " + mainStopwatch.ElapsedMilliseconds + " milliseconds"); mainStopwatch.Restart(); GetPageDetails(allLinks, ieDriver, mainStopwatch); DownloadObjects(); SaveToExcel(); Console.ReadLine(); }