an easy way to automate complex ui

40
An easy way to automate complex UI Test automation practices and tips

Upload: ivan-pashko

Post on 19-Mar-2017

94 views

Category:

Presentations & Public Speaking


2 download

TRANSCRIPT

Page 1: An easy way to automate complex UI

An easy way to automate complex UI

Test automation practices and tips

Page 2: An easy way to automate complex UI

About me

7+ years in IT Automation Engineer Scrum Master Betsson project, Ciklum

Page 3: An easy way to automate complex UI

What we have

Payments Solution for online casino 20+ brands 7+ countries 40+ payment methods Payment Pages UI (Desktop, mobile,

adaptive) Brand specific features

Page 4: An easy way to automate complex UI

Complex UI?*

*from automation perspective

Page 5: An easy way to automate complex UI

Complex UI? Complex fronted:

Dynamic Async Adaptive

Complex backend: Hardly configurable Overflown Slow Unstable

Page 6: An easy way to automate complex UI

Complex tests

Complex behavior Complex architecture Slow Fragile Overflown with scenario's «Test smells» *

*http://xunitpatterns.com/TestSmells.html

Page 7: An easy way to automate complex UI

What automation we want?

Easy to writeClear to understandSimple to work with

Page 8: An easy way to automate complex UI

Agenda

Fakes & test doubles Test & Patterns Tips and tricks (test sugar & screenshots)

Page 9: An easy way to automate complex UI

Fakes & test doubles

Page 10: An easy way to automate complex UI

Test doubles

We replace a component on which the SUT depends with a "test-specific equivalent.“

Test Stub Mock Object Fake Object

Page 11: An easy way to automate complex UI

Test doubles

Web partWebApiCore SystemDB3rd systems

Page 12: An easy way to automate complex UI

Test doubles

Web partWebApi / FakeCore SystemDB3rd systems

Page 13: An easy way to automate complex UI

What can we solve with Fake

Test without dependent components … without Backend… without 3rd Party services… without DB

Test unavailable component Simplify scenarios precondition Fix Slow/ Fragile / Heavyweight tests

Page 14: An easy way to automate complex UI

Static Fake

Static Fake – hardcoded behavior of dependent component.

Page 15: An easy way to automate complex UI

Static Fake. Pros

Have all specific behaviorsAny language for implementation*Use for prototyping & local testingSpeedup tests

*Sometimes it very hard to mock backend on JavaScript

Page 16: An easy way to automate complex UI

Static Fake. Cons

It is not easy to implementTest scenarios are not clearSupport

Page 17: An easy way to automate complex UI

Dynamic Fake

Configurable Fake Object - a reusable Test Double with the configurable values to be returned or verified during the fixture setup phase of a test.

Page 18: An easy way to automate complex UI

Dynamic Fake. Pros

Have all specific behaviorsConfigured from testScenarios are clear & readable

Page 19: An easy way to automate complex UI

Dynamic Fake. Cons

Much harder for developmentCan’t/hard to used for prototyping or local

testing

Page 20: An easy way to automate complex UI

Pitfalls

Fake – not a silver bulletAdditional test layer:

Contract tests on fake/depended component

Do not test Fake, test SUT

Page 21: An easy way to automate complex UI

Tests and Patterns

Page 22: An easy way to automate complex UI

Tests & Patterns. Problems

Scenarios duplicates Overflown locators / base classes /behavior Tones of code Inheritance hell

Page 23: An easy way to automate complex UI

PageFactory

PageFactory + [Attributes] Factory return needed page based on SiteName, PaymentMethod,

IsMobile No new for Page Object creation Fallback (from brand to common)

Result: ~ -55% duplicates in test scenarios. Test request needed page from Factory (same method for all

brands) Test prepares and transmits data to PageObject

Page 24: An easy way to automate complex UI

PageFactory

Page 25: An easy way to automate complex UI

Common Naming

XPath and component @data-name attribute

Result: ~ -35% PageObject duplicates. Similar payment method pages are not duplicated

Page 26: An easy way to automate complex UI

Template Method

Define the skeleton of an algorithm in an operation, deferring some steps to client subclasses.

Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure

Page 27: An easy way to automate complex UI

Template Method

Behavioral interfaces for each componentIReceiptPage BankReceiptPage|

WizardMobileReceiptPage|..ReceiptPageBase – with complex step definition

Result: Logic encapsulated from base class to each

component implementation

Page 28: An easy way to automate complex UI

Strategy Pattern

Strategy pattern - enables an algorithm's behavior to be selected at runtime.

Page 29: An easy way to automate complex UI

Strategy Pattern

Page 30: An easy way to automate complex UI

Strategy Pattern

Strategy pattern on element-component: IMonthYearComponent

Select2MonthYearComponent| SelectMonthYearComponent | InlineMonthYearComponent

PageFactory init strategy context

Result: ~ -60% duplicates in PageObjects All Brand-specific features overrides were

removed

Page 31: An easy way to automate complex UI

Tests & Patterns

Scenarios duplicates

Overflown locators / base classes /behavior

Tones of code Inheritance hell

Factories Common naming Patterns

Template methodStrategy

Page 32: An easy way to automate complex UI

Tests sugar. Screenshots

Page 33: An easy way to automate complex UI

Test sugar

SpecFlow & Given-When-Then structure Given - only preconditions When - all actions Then - only asserts

Page 34: An easy way to automate complex UI

Screenshots on each test step

Page 35: An easy way to automate complex UI

Screenshots in tests

SpecFlow [AfterStep] Screenshot all steps Keep history

Page 36: An easy way to automate complex UI

Screenshots. Visual testing

Use extra step Continue on failure Use emulations Hardcode/Ignore dynamic values

Page 37: An easy way to automate complex UI

How to make your life easier?

Fake complex backend Simplify your architecture

apply patterns use best practices

Improve test feedback – use text, visual information

Page 38: An easy way to automate complex UI

What automation we get?

Easy to writeClear to understandSimple to work with

Page 39: An easy way to automate complex UI

That's all folks! Questions?