Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using OpenQA.Selenium;
- using OpenQA.Selenium.Firefox;
- using OpenQA.Selenium.Support.UI;
- using System;
- using System.Collections.Generic;
- public class Program
- {
- private static void Main(string[] args)
- {
- // The Firefox driver supports javascript
- IWebDriver driver = new FirefoxDriver();
- // Go to the Google Suggest home page
- driver.Navigate().GoToUrl("http://www.google.com/webhp?complete=1&hl=en");
- // Enter the query string "Cheese"
- IWebElement query = driver.FindElement(By.Name("q"));
- query.SendKeys("Cheese");
- // Wait for suggestion box
- new WebDriverWait(driver, TimeSpan.FromSeconds(5))
- .Until(ExpectedConditions.ElementIsVisible(By.ClassName("sbsb_b")));
- // And now list the suggestions
- var allSuggestions = driver.FindElements(By.XPath("//*[contains(@id, 'sbse')]"));
- foreach (IWebElement suggestion in allSuggestions)
- {
- Console.WriteLine(suggestion.Text);
- }
- driver.Quit();
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement