void get(java.lang.String url)
void quit()
WebDriver.TargetLocator switchTo()
WebElement findElement(By by)
WebElement element = driver.findElement(By.id("element"));
List<WebElement> element = driver.findElement(By.name("name"));
By.id(«idOfObjects»)
By.linkText(«TextUsedInTheLink»)
By.partialLinkText(«partOfThelink»)
By.tagName(«theHTMLNodeType»)
By.className(«cssClassOnTheElement»)
By.cssSelector(«cssSelectorToTheElement»)
By.xpath(«//Xpath/to/the/element»)
By.name(«nameOfElement»)
driver.get("http://google.com");
driver.findElement(By.id("element_id")).click();
public class WebDriverExample {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Selenium");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("selenium");
}
});
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}