Perils of Page-Object Pattern

31
PERILS OF PAGE-OBJECT PATTERN Anand Bagmar Test Practice Lead 1

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 of Perils of Page-Object Pattern

Page 1: Perils of Page-Object Pattern

PERILS OF PAGE-OBJECT PATTERN

Anand Bagmar

Test Practice Lead 1

Page 2: Perils of Page-Object Pattern

@BagmarAnand

about.me/anand.bagmar

ABOUT ME

Page 3: Perils of Page-Object Pattern

WHAT DO YOU EXPECT FROM THIS SESSION?

Page 4: Perils of Page-Object Pattern

What is Test Automation?

Page 5: Perils of Page-Object Pattern

Automation – A Safety Net

Page 6: Perils of Page-Object Pattern

Case Study

Page 7: Perils of Page-Object Pattern
Page 8: Perils of Page-Object Pattern

START OF AN AUTOMATION FRAMEWORK

Page 9: Perils of Page-Object Pattern

Code sample - #1

Page 10: Perils of Page-Object Pattern

WILL THIS WORK? WHAT PROBLEMS EXIST?

Page 11: Perils of Page-Object Pattern

Order out of Chaos!

Page 12: Perils of Page-Object Pattern

WHAT IS A PATTERN?

Page 13: Perils of Page-Object Pattern

WHY PAGE OBJECT? WHAT IS IT?

Model pages in code

Simulates user actions

One place change

Reduces code duplication

Snippets of page

Page 14: Perils of Page-Object Pattern
Page 15: Perils of Page-Object Pattern

AUTOMATION FRAMEWORK WITH PAGE OBJECTS

Page 16: Perils of Page-Object Pattern

Code sample - #2

Page 17: Perils of Page-Object Pattern

If you keep the Automation Framework Principles and

Practices in mind …

Page 18: Perils of Page-Object Pattern

PRINCIPLES FOR A TEST AUTOMATION FRAMEWORK

Code quality

Design Patterns

Abstraction Layers

Refactor, Evolve & Extend

Pairing

Page 19: Perils of Page-Object Pattern

PRACTICES FOR A TEST AUTOMATION FRAMEWORK

Configurable

No Copy-Paste

Continuous Integration (CI)

Test Data

Tools & Utilities -  Logging -  Screenshots -  Video

Page 20: Perils of Page-Object Pattern

AUTOMATION FRAMEWORK WITH PAGE OBJECTS

Page 21: Perils of Page-Object Pattern

Code sample - #3

Page 22: Perils of Page-Object Pattern

APPLICABLE FOR

Page 23: Perils of Page-Object Pattern

TIPS

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

Ø Logical grouping

Ø Handle waits

Page 24: Perils of Page-Object Pattern

LIMITATIONS OF PAGE-OBJECT PATTERN

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

Page 25: Perils of Page-Object Pattern

Manual / Exploratory UI

Web Service

View

JavaScript

Integration

Unit

Time

Value

Cost

IDEAL TEST AUTOMATION PYRAMID

Business-facing Tests

Technology-facing Tests

Page 26: Perils of Page-Object Pattern

26

BUSINESS-LAYER PAGE-OBJECT PATTERN

Page 27: Perils of Page-Object Pattern

Code sample - #4

Page 28: Perils of Page-Object Pattern

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

Page 29: Perils of 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

Page 30: Perils of Page-Object Pattern

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

Page 31: Perils of Page-Object Pattern

[email protected] [email protected]

@BagmarAnand

about.me/anand.bagmar

THANK YOU