This document discusses WebDriver, a tool for automating browser testing. It can be used for functional testing, especially of applications that grow in complexity over time. WebDriver supports Firefox, Chrome, and Internet Explorer. It provides benefits like quick feedback on failures through continuous integration and regression testing. When automating tests, we usually focus on testing functionality rather than everything due to costs. The document provides examples of how to structure automation test projects, including breaking pages into individual page objects and organizing tests.
14. Project structure
A page...
public class SubmitFormPage extends PageObject{
public SubmitFormPage (WebDriver driver) {super(driver);}
@FindBy(id = "nameInputID")
public WebElement inputNameField;
public void inputName(String name){
inputNameField.sendKeys(name);
}
}
(WebDriver) that lets you mimic actions or interact with a web page.
*API - Application programming interface - in term this means it is not language specific. You can write your code in the language of your choice.
It is most commonly used as a Functional Testing tool.
For applications with complex business logic, not necessarily large applications.
For applications that tend to grow in complexity over time.
Automation provides a quick report on the application state or broken flows.
Quick feedback on failed deploys.
Regression suite usually has around 100 or more tests covering most of the implemented functionality.
Note: There are compatibility issues between browsers, thus meaning custom implementation for actions in certain browsers may be required.
Continuous integration (CI) is a software engineering practice in which isolated changes are immediately tested and reported on when they are added to a larger code base.
In our project setup, it is fully supported.
Most CI tools like Jenkins, Hudson, Bamboo, etc. are supported. -(others: CruiseControl, Teamcity
Part of the CI setup the functional tests may be started after each application deploy.
The time it would take to automate everything is not time and cost effective.
We also don’t test layouts or rendering. This can be achieved with other tools or through manual testing.
We usually test functionality , the short list of which would be:
application specific flows
negative flows
content validation
known issues or Bugs
in some cases services - Eg. email notifications
Applications usually come with specifications, user flows – those are the main focus of automation.
*Heaps - 1. A group of things placed or thrown, one on top of the other. 2. A great deal; a lot
These “Heaps” of functionalities get broken down in user stories, which in term will get prioritized (by importance or severity) and then go into automation.
We aim for a simple structure
We need a structure that can scale and its Easy to understand and follow
- We also need to correlate with the actual application layout for future reference. – (~Next Slide~)
Projects are broken down in three major areas. Pages , Steps and Test
Some other packages as requirements, resources and tools also live in the same project – but are not the focus for this talk
We use 3 types of classes:
Pages - html element mappings and basic actions
Steps - groups of page actions organised in steps ---
A step class can use multiple pages
A page can be invoked in multiple steps
Test - consecutive steps that are organised in application flows ---
Tests will use only the steps that are needed to achieve the “user story” or the flow
The Page class is not in a 1 to 1 relation with a webpage.
pages are broken down by functionality.
for example A header page may apply on multiple webPages so in turn is is mapped as a single entity with reusability in mind.
This is how an actual “page” looks like.
the webDriver is inherited from the PageObject.
it contains an element mapping – the element is identified by id
and a action is also defined for the element – inputName – which will send the provided keys to the element.