perils of page-object pattern

Post on 07-Nov-2014

761 Views

Category:

Software

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Page-Object pattern is very commonly used when implementing Automation frameworks. However, as the scale of the framework grows, there is a limitation on how much reusability really happens. It inherently becomes very difficult to separate the test intent from the business domain. I talk about this problem, and the solution I have been using - Business Layer - Page-Object pattern, which has helped me keep my code DRY. For more details (links to slides, etc.), see my blog: http://goo.gl/biRn4n

TRANSCRIPT

PERILS OF PAGE-OBJECT PATTERN

Anand Bagmar

Test Practice Lead 1

@BagmarAnand

about.me/anand.bagmar

ABOUT ME

WHAT DO YOU EXPECT FROM THIS SESSION?

What is Test Automation?

Automation – A Safety Net

Case Study

START OF AN AUTOMATION FRAMEWORK

Code sample - #1

WILL THIS WORK? WHAT PROBLEMS EXIST?

Order out of Chaos!

WHAT IS A PATTERN?

WHY PAGE OBJECT? WHAT IS IT?

Model pages in code

Simulates user actions

One place change

Reduces code duplication

Snippets of page

AUTOMATION FRAMEWORK WITH PAGE OBJECTS

Code sample - #2

If you keep the Automation Framework Principles and

Practices in mind …

PRINCIPLES FOR A TEST AUTOMATION FRAMEWORK

Code quality

Design Patterns

Abstraction Layers

Refactor, Evolve & Extend

Pairing

PRACTICES FOR A TEST AUTOMATION FRAMEWORK

Configurable

No Copy-Paste

Continuous Integration (CI)

Test Data

Tools & Utilities -  Logging -  Screenshots -  Video

AUTOMATION FRAMEWORK WITH PAGE OBJECTS

Code sample - #3

APPLICABLE FOR

TIPS

Especially in Data / Locator heavy pages Ø No getters / setters

Ø Logical grouping

Ø Handle waits

LIMITATIONS OF PAGE-OBJECT PATTERN

Test intent gets polluted Duplication of Test intent & implementation Intent becomes Imperative Maintenance challenges Scaling challenges

Manual / Exploratory UI

Web Service

View

JavaScript

Integration

Unit

Time

Value

Cost

IDEAL TEST AUTOMATION PYRAMID

Business-facing Tests

Technology-facing Tests

26

BUSINESS-LAYER PAGE-OBJECT PATTERN

Code sample - #4

ADVANTAGES

Validate what is important - Business requirements Test Pyramid remains sane Abstraction layers allow separation-of-concerns Changes are isolated Maintenance & Scaling becomes ‘easier’

Advantages of Business-Layer

Page-Object Pattern

TEST AUTOMATION FRAMEWORK BEST PRACTICES

Assertions & Validations In Business Layer

Model Test Data

Proper abstraction layers

Pages as Dummy objects

Evolve

Programming practices

OOPs Design Patterns

Identify intent in business terminology

Build Tools & Utilities

REFERENCES

Page Objects – Google

https://code.google.com/p/selenium/wiki/PageObjects

Page Objects – Martin Fowler

http://martinfowler.com/bliki/PageObject.html

Test Design Consideration

http://docs.seleniumhq.org/docs/06_test_design_considerations.jsp

abagmar@gmail.com Anand.Bagmar@thoughtworks.com

@BagmarAnand

about.me/anand.bagmar

THANK YOU

top related