Web Test Automation Flashcards
Levels of Testing
UAT
System Testing
Integration Testing
Unit Testing
Selenium
API based approach to web testing, supporting multiple browsers and languages. It handles frames, browser windows, popups and alerts, AJAX, and drag and drop.
There are two main objects
Driver and WebElement
Driver
Allows interaction with browser, navigation, access to source, finding elements etc.
WebElement
Encapsulates elements within a page. Allows querying (getText(), getValue() etc.) and Interaction (click(), submit() etc.)
Elements can be located by
Id, Css classname, name, link text, tag name or Xpath.
findElement()
returns the first element that matches the locator, throws exception if not found
findElements()
returns a list of all webElement objects that match your locator, returns an empty list if none are found.
Timing Issues
Sometimes elements may appear dynamically on the page, you may not know how long they will take to appear. Bad practice is to use something like Thread.sleep(5000);
Good practice would be to use WebdriverWait wait = new WebDriverWait(webDriver, timeout); wait.unit(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));</locator>
Page Object Design Pattern
An abstraction mechanism, consists of creating an object model around your web front end. Makes tests more maintainable and readable. Pass in a WebDriver through constructor, implement methods of interest and use methods in test.