32
APIs: A Better Alternative to Page Objects Eileen Xie Head of Quality at PBworks #sfse 8/23/11

APIs: A Better Alternative to Page Objects

Embed Size (px)

DESCRIPTION

Eileen Xie, Head of #sfse lightning takls

Citation preview

Page 1: APIs: A Better Alternative to Page Objects

APIs: A Better Alternative to Page Objects

Eileen XieHead of Quality at PBworks

#sfse 8/23/11

Page 2: APIs: A Better Alternative to Page Objects

Page Objects

Page 3: APIs: A Better Alternative to Page Objects

What are they trying to solve?

Page 4: APIs: A Better Alternative to Page Objects

What are they trying to solve?

• repetition

• maintenance

• readability

Page 5: APIs: A Better Alternative to Page Objects

How well do they solve them?

Page 6: APIs: A Better Alternative to Page Objects

How well do they solve them?

• repetition: poorly

• maintenance: poorly

• readability: poorly

Page 7: APIs: A Better Alternative to Page Objects

Repetition

Page 8: APIs: A Better Alternative to Page Objects

Repetition

• still too many steps

• some steps repeated over and overhomePage = HomePage.load();loginPage = homePage.getLoginLink().click();welcomePage = loginPage.login();newTaskPage = welcomePage.getNewTaskLink().click();newTaskPage.getTaskNameField().type(“Learn Selenium”);

Page 9: APIs: A Better Alternative to Page Objects

Maintenance

Page 10: APIs: A Better Alternative to Page Objects

Maintenance

• huge overhead

• QA needs to maintain and fix

• still dependent on page workflow

• still dependent on page structure/layout

Page 11: APIs: A Better Alternative to Page Objects

Readability

Page 12: APIs: A Better Alternative to Page Objects

Readability

• see repetition

Page 13: APIs: A Better Alternative to Page Objects

What can we do instead?

Page 14: APIs: A Better Alternative to Page Objects

What can we do instead?

• APIs!

Page 15: APIs: A Better Alternative to Page Objects

APIs

Page 16: APIs: A Better Alternative to Page Objects

What do they look like?

Page 17: APIs: A Better Alternative to Page Objects

createNetwork();

createNetworkWorkspace();

addNetworkUser();

What do they look like?

Page 18: APIs: A Better Alternative to Page Objects

What do they look like under the hood?

Page 19: APIs: A Better Alternative to Page Objects

What do they look like under the hood?

function createNetworkFolder(name) {curl(“http://pbworks.com/api_v2/op/CreateNetworkFolder/name/” + name);

}

Page 20: APIs: A Better Alternative to Page Objects

What?

• Where’s all the code?

• Why would we do this?

• How do the API calls get tested?

• How do we start?

• Wait a minute...

Page 21: APIs: A Better Alternative to Page Objects

Where’s all the code?

Page 22: APIs: A Better Alternative to Page Objects

Where’s all the code?

• in the product!

• really.

Page 23: APIs: A Better Alternative to Page Objects

Why would we do this?

Page 24: APIs: A Better Alternative to Page Objects

Why would we do this?

• less repetition

• makes tests clearer

• maintained by developers

• easier to read

• makes software more testable

• test execution speed

• better than straight SQL insertions

Page 25: APIs: A Better Alternative to Page Objects

How do the API calls get tested?

Page 26: APIs: A Better Alternative to Page Objects

How do the API calls get tested?

• separate tests!

• one test does the API stuff through the UIdashboardPage.getNewTaskLink().click();newTaskPage.getTaskNameField().type(“Learn Selenium”);newTaskPage.getTaskDueDateField().type(“8/31/11”);

• every other test calls the APIcreateTask();

Page 27: APIs: A Better Alternative to Page Objects

How do we start?

Page 28: APIs: A Better Alternative to Page Objects

How do we start?

• figure out what the functions are

• talk to your devs!

• start with new functionality

• greenfield projects

Page 29: APIs: A Better Alternative to Page Objects

Wait a minute...

Page 30: APIs: A Better Alternative to Page Objects

Wait a minute...

• requires a ton of cooperation from devs

• huge upfront cost

• doesn’t actually replace page objects

Page 31: APIs: A Better Alternative to Page Objects

Summary

• APIs are awesome

• ...and a pain in the ass to start using

• complimentary to page objects