Top Banner
Test Automation Framework Introduction – Data Driven (Free to Share/View/Download) Presenter : Ganuka Yashantha © Ganuka Yashantha | [email protected]
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Test Automation Framework Development Introduction

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

Presenter : Ganuka Yashantha© Ganuka Yashantha | [email protected]

Page 2: Test Automation Framework Development Introduction

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 | [email protected]

Page 3: Test Automation Framework Development Introduction

Software Test Framework What is a software test framework?

1© Ganuka Yashantha | [email protected]

Page 4: Test Automation Framework Development Introduction

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 | [email protected]

Page 5: Test Automation Framework Development Introduction

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 | [email protected]

Page 6: Test Automation Framework Development Introduction

SELENIUM 2.0 What is the easy way to automate?

2© Ganuka Yashantha | [email protected]

Page 7: Test Automation Framework Development Introduction

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 | [email protected]

Page 8: Test Automation Framework Development Introduction

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 | [email protected]

Page 9: Test Automation Framework Development Introduction

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 | [email protected]

Page 10: Test Automation Framework Development Introduction

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 | [email protected]

Page 11: Test Automation Framework Development Introduction

The Better WayWhat could be a

better way of automating?

3© Ganuka Yashantha | [email protected]

Page 12: Test Automation Framework Development Introduction

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 | [email protected]

Page 13: Test Automation Framework Development Introduction

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 | [email protected]

Page 14: Test Automation Framework Development Introduction

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 | [email protected]

Page 15: Test Automation Framework Development Introduction

The better wayPageObject class more…

© Ganuka Yashantha | [email protected]

Once new Element added to the DOM below Xpaths’ can

be changed….

Page 16: Test Automation Framework Development Introduction

DataObject Class

Getter and Setters

Test Data

© Ganuka Yashantha | [email protected]

Page 17: Test Automation Framework Development Introduction

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 | [email protected]

Page 18: Test Automation Framework Development Introduction

TestExecution Class

© Ganuka Yashantha | [email protected]

Data passing from Data Object

Creating login data Object

Using LoginPageObject

to navigate

Normal Test Execution

Page 19: Test Automation Framework Development Introduction

Engine

Continues ….

© Ganuka Yashantha | [email protected]

Page 20: Test Automation Framework Development Introduction

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 | [email protected]

Page 21: Test Automation Framework Development Introduction

Automation Framework

Different type of automation

frameworks?

4© Ganuka Yashantha | [email protected]

Page 22: Test Automation Framework Development Introduction

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 | [email protected]

Page 23: Test Automation Framework Development Introduction

Lessons LearntSome important

points to keep in mind

© Ganuka Yashantha | [email protected]

Page 24: Test Automation Framework Development Introduction

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 | [email protected]

Page 25: Test Automation Framework Development Introduction

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

© Ganuka Yashantha | [email protected]

Scripts can fail

Page 26: Test Automation Framework Development Introduction

When using ID’s

© Ganuka Yashantha | [email protected]

Page 27: Test Automation Framework Development Introduction

Thank You

© Ganuka Yashantha | [email protected]