Upload
sauce-labs
View
1.544
Download
0
Embed Size (px)
Citation preview
© Sauce Labs, Inc.
Three Approaches to Optimizing Your Selenium Test Designs
Presented by QualiTest and Sauce Labs, Inc.11/4/2015
© Sauce Labs, Inc.
Brian Van Stone – Solutions Architect, QualiTest
Neil Manvar – Solutions Architect, Sauce Labs
© Sauce Labs, Inc.© Sauce Labs, Inc.
Agenda
Good design approaches with Selenium
Different types of test designs• Page Object Model• Behavior Driven Development• Keyword Driven Design
Pros and cons of design methodologies
Q&A
© Sauce Labs, Inc.
The Importance of Design
• Key Success Factors in Test Automation
• Strong Design• Consistency• Reliability
• Benefits• Faster development• More accurate results• Reduced cost of
maintenance• Ability to address absent
features of Selenium
© Sauce Labs, Inc.
Page Object Design Pattern
• Definition: Model the UI components of your application as Page Objects which:• Expose the services of a page to the test developer• Abstract the deep knowledge of page structure away from the test
• Disadvantages:• Cost of framework development• Not ideal for all applications
• Some pages can be highly interactive and serve a very large amount of content
• Requires a high degree of technical proficiency from the testing team
• Advantages:• High tolerance of changes in the UI• Intuitive model for automating workflow
driven functionality• Parallelism with other design patterns like
MVC• Reduction in code duplication• Coupling of object recognition and app
functionality
© Sauce Labs, Inc.
Why Page Object?
• Reasons to consider page object design:
• Large amounts of workflow driven content that lends itself to page-by-page automation
• Leveraging synergy with a development team employing the MVC design pattern
• Separation of implementation from presentation reduces maintenance costs
• Reasons to explore other options:
• Large amounts of highly interactive single-page content. This is becoming less common than it once was.
• Requirement or desire to involve non-technical SMEs in the test design and execution processes
© Sauce Labs, Inc.
Page Object Sample and Further Discussion
© Sauce Labs, Inc.
BDD
• BDD = Behavior Driver Development
• maintainable, readable, easy to debug
• Test Automation Framework• Cucumber• Selenium-Webdriver• Page-Object• Selenium-Webdriver
© Sauce Labs, Inc.
Testing using BDD Tools - Pro / Cons
• Pros• Requirements and Behavior are clear• Can be read / understood by all• Easier to debug and maintain• Test case is from a “user” perspective
• Cons• Another layer / technology that is introduced
into tech stack• Onboarding – how to write proper step
definitions, features, scenario outlines, regex’s, etc.
© Sauce Labs, Inc.
Keyword Driven Testing (KDT)
• Definition: Represent functionality to be tested as keywords which are executed in combination to model test behavior
• Disadvantages:• Risk of dependency creation between
keywords must be mitigated by design• Sometimes such dependencies are
unavoidable• Maintenance costs are generally
managed more by design than by technical savvy.
• Addresses only application functionality rather than application objects
• Requires additional design of an object recognition strategy
• Advantages:• Strong and clear separation of
design, data, and development• Capacity to understand test
automation flow without much or any technical knowledge
• Extreme abstraction of automation implementation
© Sauce Labs, Inc.
Why KDT?
• Reasons to consider KDT:• Culture and support structure
tending towards business driven test design
• Separation of design, data, and development
• Organizational structure will sometimes lend these three categories to different existing roles in the organization
• Requirement to have non-programming personnel interact with test automation (design, execution, or analysis)
• Very easy to data-drive tests
• Reasons to explore other options:• Large amounts of dependent
functionality• You can model workflows in KDT
but complex workflows can present issues
• Desire to keep test automation technical and reduce design overhead
© Sauce Labs, Inc.
KDT Sample and Further Discussion
• Start with a generic keyword• Create a concept for an execution
flow• Make sure keyword execution can
handle exception cases• Devise a strategy for sharing data
between keywords and/or tests
© Sauce Labs, Inc.
KDT Sample and Further Discussion
• Create the core of the framework that enables execution of tests
• Create a primary driver class which can parse your input (driven by spreadsheet, xml files, JSON, etc.)
• Control execution flow at the highest level here. Have a hierarchy of classes to support each level (Test Cases, Keywords, etc.)
• The most light weight means of execution will be driving it through a main method and simply invoking it from the command line
• Reflection is your friend
© Sauce Labs, Inc.
KDT Sample and Further Discussion
• With the core framework in place, build useful and reusable keywords
• This is a prototype for a keyword that manages connections
• Create an abstract class which manages connection creation/reuse during initialization
• And manages connection cleanup/rollback during cleanup
© Sauce Labs, Inc.
KDT Sample and Further Discussion
• Create simple keywords leveraging abstract functionality
• Keywords that perform a specific task should perform ONLY that task whenever possible
• A specific keyword implementation should only care about the arguments unique to it
• Reduce maintenance costs by eliminating boiler plate or common code
© Sauce Labs, Inc.
Summary
• Key Takeaways• Design, design, design• Focus on reducing maintenance costs• Choose the best fit
© Sauce Labs, Inc.
Questions?
© Sauce Labs, Inc.
More Info on Sauce Labs
Resources• WhitePaper: How to get the most out of your CI / CD work flow with
automated testinghttp://tinyurl.com/p5umo6p
• Sauce Labs Docs – tutorials for writing scriptshttps://docs.saucelabs.com/
• Sign up for a free trial of Saucehttps://saucelabs.com/signup/trial
© Sauce Labs, Inc.
More Info QualiTest
Resources• Check us out!
http://www.qualitestgroup.com
• See some stories of what we have done with Selenium!http
://www.qualitestgroup.com/software-testing/testing-services-through-selenium/
© Sauce Labs, Inc.
Thank you!