Web driver
driver?
SEleNIUM
WEB DRIVER
To test, or not to test, that is the question
![](https://s3.amazonaws.com/media-p.slid.es/uploads/693073/images/3693044/W3C__Icon.svg.png)
Interface? Usability?
Integration!
Let’s work…
Browser + Driver + Script
Basic concepts…
-
WebDriver
-
WebElement
-
By
Main functions…
-
void get(java.lang.String url)
-
void quit()
-
WebDriver.TargetLocator switchTo()
-
WebElement findElement(By by)
Find elements…
WebElement element = driver.findElement(By.id("element"));
List<WebElement> element = driver.findElement(By.name("name"));
BY…
-
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»)
Basic
operations
on elements…
- void click()
- void submit()
- String getValue()
- void sendKeys(keysToSend)
- void clear()
- String getElementName()
- String getAttribute(java.lang.String name)
WAits…
-
Implicit Wait
-
Explicit Wait
driver.get("http://google.com");
driver.findElement(By.id("element_id")).click();
Simple programm…
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();
}
}
Thanks.
Web driver
By Victoria Budyonnaya
Web driver
- 135