26
ELIAS NOGUEIRA TATIANE NOGUEIRA @eliasnogueira @tatianeaguirres

ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Embed Size (px)

Citation preview

Page 1: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

ELIAS NOGUEIRA TATIANE NOGUEIRA@eliasnogueira @tatianeaguirres

Page 2: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

TATIANE NOGUEIRAConsultant Developer @ Thoughtworks

@tatianeaguirreslinkedin.com/tatianeaguirres

ELIAS NOGUEIRASoftware Engineer in Test @ Sicredi

@eliasnogueiralinkedin.com/eliasnogueira

Page 3: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

THE STACK

LANGUAGE TESTING INFRADATA GENERATION

javafaker

LOG & REPORTS

ExtentReports

Page 4: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

PAGE OBJECT MODEL• Page Objects• Page Factory• Abstraction• Waiting Strategy

PARALLEL EXECUTION• Infrastructure• Containers

LOGS AND REPORTS• Exception logs• General reports• Evidence

DATA GENERATION• Fake

• Static creation• Dynamic creation

PIPELINE• Execution strategy

BASE ARCHITECTURE• Clean Architecture• Design Patters• Testing Patterns

BASIC ITEMS FOR A TEST ARCHITECTUREwith focus on web automation

Page 5: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

an abstract class that will take care of commons actions in your automated tests

FACTORY the Design Pattern to create, in our case, browser instances

LISTENERa non-intrusive way to know what is happening during the test execution

BASE TEST

BASE ARCHITECTUREto apply DRY and KISS

Page 6: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Smart use of inheritance• test inherit common test actions

One test case per class• provide an easy way to add more tests• ease division of tests in suites

BASE TEST CLASS TEST 1

TEST 2

TEST N

• browser initialization/close• open/close database, logs …• connect/disconnect servers• login/logout app

BASE TEST CLASS

Page 7: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Apply Factory Design Pattern will help us to create a browser instance and make easy the parallel execution against many environments.

BROWSER FACTORY

chrome firefox edge

FACTORY CLASS

safari

Page 8: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Using TestNG we can use some listeners that allow modifying (or just watch) the test behaviors. Helpful o watch test lifecycle and do something.

LISTENERS

MY TEST LISTENER

• test start• test finish• on test fail• on test skipped• on start• on finish• on success

TEST 1

@MyTestListener

TEST 2

@MyTestListener

TEST N

@MyTestListener

Page 9: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

way to create more readability service class

LOAD STRATEGY

making the code wait for async executions

FLUENT INTERFACE

create tests in a fluent way

PAGE FACTORY

PAGE OBJECTS MODELmore maintainability and readability

Page 10: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

TESTSPAGE OBJECTSAPP PAGES

PAGE OBJECTSPage Object is a class that serves as an interface to a page of your web page.The class provides methods to do the page actions.Tests will use these methods.

PAGE OBJECTFLIGHT SELECTION

PAGE OBJECTSEARCH

PAGE OBJECTPAYMENT

SUCCESSFUL BOOK

INVALID DATES

SEARCH PAGE

FLIGHT SELECTION PAGE

PAYMENT PAGE PAYMENT PROBLEM

Page 11: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

LOAD STRATEGYA Load Strategy is responsible for wait for a certain time by any event on the web page, most of the time related to async requests (Ajax).

PAUSE

IMPLICITLY

any type of sleep that will pause the execution

you’ll won’t know, in your code witch action will wait

EXPLICITLY

AJAX LOCATORthe best choice to use with Page Factory strategy

with this strategy you can see, in the code, witch element will take time

Page 12: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

FLUENT INTERFACECreates a method chaining to perform a series of actions to make the code more readable and easy to use.

@Testpublic void testWithoutFluentInterface() {

GeneralMenuPage menu = new GeneralMenuPage();menu.clickinExperience();menu.clickInOurFleet();menu.clickInSeatingCharts();

}

@Testpublic void testWithFluentInterface() {

GeneralMenuPage menu = new GeneralMenuPage();menu.clickinExperience().clickInOurFleet().clickInSeatingCharts();

}

Page 13: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

know all the exceptions to solve the problems root-cause

GENERAL REPORTS

evidence and executive reports

EXCEPTIONLOGS

LOGS AND REPORTSbecause we need to know about any error

Page 14: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

By using any log strategy, saving a log file, we can understand the common errors occurred during the test execution.

These errors can be of:• assertion errors• timeout exceptions• locator exception• an exception on your architecture

If you want to analyze test errors across teams a good way is using Elasticsearch with Grafana/Kibana.

EXCEPTION LOGS

Page 15: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Generate xUnit reports to attach on your CI/CD and, rapidly, see the test status.

GENERAL REPORTS

Create an executive report to provide information and evidence about the test execution.

This report may contain screenshots when an error occurs to help to analyze the root cause of a problem.

Page 16: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

pass the responsibility of non-sensitive data generation to a framework

STATIC/DYNAMIC GENERATION

create the sensitive data and put under your control

FAKES

DATA GENERATIONsolve one of the biggest problems

Page 17: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

Ability to create an approach to generate non-sensitive data for your test without the necessity to manually change the test data in each execution.

There’re a lot of tools to create these type of data.

FAKE GENERATION

Example with javafaker

Faker faker = new Faker(new Locale("pt-BR"));

faker.name().fullName();faker.address().fullAddress();faker.internet().emailAddress();faker.business().creditCardNumber();faker.date().birthday();

Page 18: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

When the data cause different behaviors in your application.

STATIC / DYNAMIC GENERATION

A Static approach can be implemented with any kind of solution, like:• Files

• CSV | JSON | TXT | YML• Database• Mock

A Dynamic approach can be created according to your context.Used for remove the maintenance of test data

• Queries in a database• Consume data from a static poll

Page 19: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

run many tests at the same time in a chosen target

GRID ANDAUTO-SCALE

using the proper containers, we can speed up the test execution

PARALLELISM

PARALLEL EXECUTIONto speed up your test execution

Page 20: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

maven-surefire-plugin

Have an ability to control how many threads we need

inside the pom.xml

Junit 4

Has an experimental class called

ParallelComputer

TestNG

Control the parallelism thought

the suites in any level of tests (class,

methods, etc..)

Parallelism, under test, is the ability to perform the same test in different conditions (browser, devices, etc...) or different tests at the same time.

PARALLELISM

Page 21: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

GRID SCHEMA

Node Windows Node MacOSX Node Linux

Test Script Hub

send capabilities

understands the capabilitiesand send to proper node

Page 22: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

WAYS TO CREATE A GRID

LOCALUses machines inside an

infrastructure. Can be a bare-metal desktop

or a virtual machine

CLOUDUses a cloud infrastructure platform to create virtual

machines

CONTAINERSUses containers (locally or cloud-based) to create the infrastructure and support

orchestration

Page 23: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

CONTAINERS TO AUTO-SCALE

• has containers for each aspect of the grid• selenium-hub• selenium-node-chrome• selenium-node-firefox

• auto-scale based on hardware utilization or with some in-house solution

• Uses a custom container elgalu/selenium that provides:

• live Preview with VNC• video recording• dashboard

• automatic auto-scale containers based on the number of tests

SELENIUM

Page 24: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

create a pipeline for any type of test execution

DIVIDE ALL TYPES OF EXECUTION

PIPELINEmake the execution process clear

Page 25: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

FUNCTIONAL TESTACCEPTANCE TESTSMOKE TEST

DIVIDE ALL TYPES OF EXECUTION

WEB PART IN THE PIPELINE

Most important tests in a business perspective

Most used user scenarios

Assure that critical functionalities

works

each build your determinatione.g.: release

Your determinatione.g.: release

Page 26: ELIAS NOGUEIRA TATIANE NOGUEIRA - static.rainfocus.com · APP PAGES PAGE OBJECTS TESTS PAGE OBJECTS Page Object is a class that serves as an interface to a page of your web page

THANK YOU!

TATIANE NOGUEIRAConsultant Developer @ Thoughtworks

@tatianeaguirreslinkedin.com/tatianeaguirres

ELIAS NOGUEIRASoftware Engineer in Test @ Sicredi

@eliasnogueiralinkedin.com/eliasnogueira

https://github.com/eliasnogueira/public-speaking