test automation framework development introduction

Post on 21-Jul-2015

97 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Test Automation Framework Introduction – Data Driven(Free to Share/View/Download)

Presenter : Ganuka Yashantha© Ganuka Yashantha | ganuyash@gmail.com

Contents1. Software Framework

2. Selenium 2.0What is Selenium

What we use

Advantages of WebDriver

1. The Better Way

Introduction

PageObject Pattern

1. Automation Framework ApproachesData/Table Driven Framework

Lessons Learnt

Test Organization

Test Writing Style

Note

© Ganuka Yashantha | ganuyash@gmail.com

Software Test Framework What is a software test framework?

1© Ganuka Yashantha | ganuyash@gmail.com

Software Test FrameworkThe definition and key components

A software test framework is a universal, reusable software platform used to develop applications, products and solutions (Wikipedia, 2012).

Software Test Frameworks include,

Support Programs

Compilers

Code Libraries

APIs

A tool set to integrate different components

© Ganuka Yashantha | ganuyash@gmail.com

Software FrameworkFramework properties

A Software Test framework contain key distinguishing features that separate them from normal libraries.

They are,

Inversion of Control (IOC) the overall program's flow of control is not dictated by the caller, but by the framework.

Default behaviour must actually be some useful behavior and not a series of instructions.

Extensibility can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.

Non modifiable framework code is not allowed to be modified.

© Ganuka Yashantha | ganuyash@gmail.com

SELENIUM 2.0 What is the easy way to automate?

2© Ganuka Yashantha | ganuyash@gmail.com

The easy wayRecords all user activities and play back

Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests.

Later, the recorded events are played back and various assertions are made to ensure the output matches that which is expected.

© Ganuka Yashantha | ganuyash@gmail.com

What is Selenium ?

create quick bug reproduction scripts

create scripts to aid in automation-aided exploratory testing

Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes

create robust, browser-based regression automation

scale and distribute scripts across many environments

Selenium IDE Selenium WebDriver

© Ganuka Yashantha | ganuyash@gmail.com

What we Use ?Selenium WebDriver

This is commonly referred to as just "WebDriver" or sometimes as “Selenium 2”

Selenium 1.0 + WebDriver = Selenium 2.0

Tests should be written in Java, the implementing classes one should use are listed as below:

AndroidDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, PhantomJSDriver, RemoteWebDriver, SafariDriver

© Ganuka Yashantha | ganuyash@gmail.com

Advantages of WebDriver

Better error handling.  You can wrap you calls in try/catch blocks and have recovery routines.

Reusable modules.  PageObject, Reusable flow models, Fixtures and Factories, data processing, object handling utilities, etc

Ability to tap into coordinate stuff outside of web browser.

Very mature and complete API

In Sept 2010, supports JavaScript alerts and confirms better

© Ganuka Yashantha | ganuyash@gmail.com

The Better WayWhat could be a

better way of automating?

3© Ganuka Yashantha | ganuyash@gmail.com

The better wayIntroduction

Treat automated testing as software development.

Tests should be created with the same concern for software design principles such as,

• Reduced coupling

• High cohesion

• Proper separation of concerns

• Maintainability

• Reusability

© Ganuka Yashantha | ganuyash@gmail.com

Automation Framework ApproachesGeneric ArchitectureA Test Automation Framework should have a multi-tiered architecture. It should consists of the following tiers.

Engine Components in this tier are completely responsible for interacting with the WebDriver interfaces.

Domain This tier is meant to contain only page objects that work against the engine.

Utils This tier is meant to contain very generic, reusable functionality across all the other tiers.

Functional Tests This tier will contain tests that are built on top of other tiers to create actual test scenarios by using page objects in the Domain.

Test Automation FrameworkTest Automation Framework

Functional Tests(Business Logic)Functional Tests(Business Logic)

Domain(Page Object)

Engine

Utils

Utils

Selenium Web Driver APISelenium Web Driver API

Data O

bjectD

ata Object

TestNG FrameWorkTestNG FrameWork

© Ganuka Yashantha | ganuyash@gmail.com

Page Object Design Pattern The Page Object pattern represents the screens of your web

app as a series of objects and encapsulates the features represented by a page.

It allows us to model the UI in our tests.

A page object is an object-oriented class that serves as an interface to a page

clickLogin –Directing to Home Page

enterPassword

enterUserName

© Ganuka Yashantha | ganuyash@gmail.com

The better wayPageObject class more…

© Ganuka Yashantha | ganuyash@gmail.com

Once new Element added to the DOM below Xpaths’ can

be changed….

DataObject Class

Getter and Setters

Test Data

© Ganuka Yashantha | ganuyash@gmail.com

Test Data GenerationUseful When Test Data Generating Preparing proper test data is a core part of testing.

Especially when you do Functional Automation testing or Performance testing you will need large number of data set.

Using following links you can make it more handily

• http://www.mockaroo.com/#tab_all

• http://www.generatedata.com/

© Ganuka Yashantha | ganuyash@gmail.com

TestExecution Class

© Ganuka Yashantha | ganuyash@gmail.com

Data passing from Data Object

Creating login data Object

Using LoginPageObject

to navigate

Normal Test Execution

Engine

Continues ….

© Ganuka Yashantha | ganuyash@gmail.com

The better wayThings to Remember….In PageObjects,

• The public methods represent the services that the page offers

• Try to stick to the ID and Name when Accessing Elements.(FindElementBy.id

or FindElementBy.name)

• Changes in UI’s having a direct impact on the PageObject Classes

• Methods return other PageObjects, if functionality changed there can be

plenty of changes in DataObjects, PageObjects and Business Logic as well.

• If there are dynamic web elements, changes in those have a impact on

Excel Data sources, Data Object and PageObject.

• Different results for the same action are modeled as different methods© Ganuka Yashantha | ganuyash@gmail.com

Automation Framework

Different type of automation

frameworks?

4© Ganuka Yashantha | ganuyash@gmail.com

Automation Framework ApproachesData Driven Framework

Data driven is the design of possible inputs what may given by the end user. This would cover

maximum probabilities of an input data. It can be a spread sheet or a DB. We have to connect

and pass the values to the respective field or element.

• Take advantage of tester’s familiarity with test case creation using tables and matrices

• Accommodate localization projects

• Recognize the importance of patterns in test cases

• Enable testers to catalog test cases with Excel spreadsheets

• Enable testers to specify expected results in spreadsheets

© Ganuka Yashantha | ganuyash@gmail.com

Lessons LearntSome important

points to keep in mind

© Ganuka Yashantha | ganuyash@gmail.com

Notes … .. .

Referred selector order : id > name > css > xpath

Using ID as a selector is the best Practise.

If there are changes in Selectors, communicate among the QAs’ and it’s important to prevent the test failures.

Automated Test Can be flailed due to :

• Selector Changes (id/name/css/xpath)

• Functionality Changes (business logic)

• Data Provider failures (updating fields/adding new fields, etc)

• External Data Level(XML Changes) Changes

© Ganuka Yashantha | ganuyash@gmail.com

When new Element added to the Navigation Panel Xpath of the “User Details’’ Element Can be changed.

© Ganuka Yashantha | ganuyash@gmail.com

Scripts can fail

When using ID’s

© Ganuka Yashantha | ganuyash@gmail.com

Thank You

© Ganuka Yashantha | ganuyash@gmail.com

top related