Page objects pattern

15
Amir Barylko - Page Objects MavenThought Inc. AMIR BARYLKO PAGE OBJECTS PATTERN WINNIPEG RUBY USER GROUP FEB 2012

description

Presentation about using the page object pattern for writing tests with cucumber

Transcript of Page objects pattern

Page 1: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

AMIR BARYLKO

PAGE OBJECTSPATTERN

WINNIPEG RUBY USER GROUPFEB 2012

Page 2: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

WHO AM I?

• Architect

•Developer

•Mentor

• Great cook

• The one who’s entertaining you for the next hour!

Page 3: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

UI TESTING (BDD)

Page 4: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

WHAT’S THE POINT?

• Flush out requirements

•Drive development

• Traceability

•Documentation

• ????

Page 5: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

WHO CARES?

• The Stakeholders

• The Developers

•QAs

• BAs

• Etc

Page 6: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

WHAT’S THE PROBLEM?

•New approach

• It’s quite a bit of effort

• Classic roles may clash

• The whole team needs to buy in

• Implementation changes may imply test changes

Page 7: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

IMPLEMENTATION

Page 8: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

FEATURES

Feature: Listing projects As a user I Want to see the list of projects So I can choose one to see the details

Scenario: List all projects Given I'm logged in And I have some projects loaded When I go to the projects page Then I should the complete list of projects

Page 9: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

STEPS

When /^I have some projects loaded$/ do

# setup the projects you have

end

Then /^I should have the complete list of projects$/ do

# some cool ruby code here to

# verify that what you are seeing is what you

# actually have in the database

end

Page 10: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

COMMON STRUCTURE

Step Cucumber Implementation

Arrange Given I have.... Put some stuff in the DB

Act When I do this...Click, enter values,

more clicking

Assert Then I should see... DB == HTML?

Page 11: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

LOOK MA! NO TAGS!

• How to avoid brittle tests?

•What do we do in general when coding?

• Reusability.... perhaps?

• Less coupling, maybe?

• How? Where?

Page 12: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

LOOK MA! NO SLIDES!

unless boring || stef.still_talking? do demo()end

Page 13: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

QUESTIONS?

Page 14: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

RESOURCES

• Email: [email protected],

• Twitter : @abarylko

• Blog: http://orthocoders.com

•Materials: http://orthocoders.com/presentations

•Website: http://maventhought.com

Page 15: Page objects pattern

Amir Barylko - Page Objects MavenThought Inc.

RESOURCES II

• PoP: http://code.google.com/p/selenium/wiki/PageObjects

• Gizmo: https://github.com/icaruswings/gizmo

• Example1: https://github.com/cheezy/uitesting_blog

• Capybara: https://github.com/jnicklas/capybara

• Cucumber: https://cucumber.org