Selenium Design Patterns and Best Practices
eBook - ePub

Selenium Design Patterns and Best Practices

Dima Kovalenko

Share book
  1. 270 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Selenium Design Patterns and Best Practices

Dima Kovalenko

Book details
Book preview
Table of contents
Citations

About This Book

Selenium WebDriver is a global leader in automated web testing. It empowers users to perform complex testing scenarios with its simple and powerful interface.

This guide will provide you with all the skills you need to successfully create a functional Selenium test suite. Starting from the very beginning of the Selenium IDE, this book will show you how to transition into a real programing language such as Ruby or Java. You will quickly learn how to improve your code quality with refactoring and the skills needed to plan for the future development of your website to future-proof your test suite. With ample test examples running against a life-like e-commerce store and detailed step-by-step code review and explanations, you will be ready to test any challenge web developers might throw your way.

This book is intended for anyone who wants to create a test suite that is easy to maintain by expanding your knowledge until you feel truly confident and comfortable with Selenium.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Selenium Design Patterns and Best Practices an online PDF/ePUB?
Yes, you can access Selenium Design Patterns and Best Practices by Dima Kovalenko in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation Web. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781783982707
Edition
1

Selenium Design Patterns and Best Practices


Table of Contents

Selenium Design Patterns and Best Practices
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Writing the First Test
Choosing Selenium over other tools
Right tool for the right job
Price
Open source
Flexibility
The Record and Playback pattern
Advantages of the Record and Playback pattern
Disadvantages of the Record and Playback pattern
Getting started with the Selenium IDE
Installing the Selenium IDE
Recording our first test
Saving the test
Understanding Selenium commands
Reading Selenese
Comparing Ruby to Selenese
Comparing Selenium commands in multiple languages
Writing a Selenium test in Ruby
Introducing Test::Unit
Introducing asserts
Interactive test debugging
Summary
2. The Spaghetti Pattern
Introducing the Spaghetti pattern
Advantages of the Spaghetti pattern
Disadvantages of the Spaghetti pattern
Testing the product review functionality
Starting a product review test
Locating elements on the page
Using a browser's element inspector
Introducing locator strategies
Using advanced locator strategies
Using the absolute path
Using the relative path
Writing locator strategy code
Using chained selector strategy methods
Using the CSS selector
Using XPath
Implementing clicks and assertions
Duplicating the product review test
Reasons for failures
The Chain Linked pattern
The Big Ball of Mud pattern
Summary
3. Refactoring Tests
Refactoring tests
The DRY testing pattern
Advantages of the DRY testing pattern
Disadvantages of the DRY testing pattern
Moving code into a setup and teardown
Removing duplication with methods
Removing external test goals
Using a method to fill out the review form
Reviewing the refactored code
The Hermetic test pattern
Advantages of the Hermetic test pattern
Disadvantages of the Hermetic test pattern
Removing test-on-test dependence
Using timestamps as test data
Extracting the remaining common actions to methods
Creating a new review with a single method call
Reviewing the test-on-test dependency refactoring
Creating generic DRY methods
Refactoring with generic methods
The random run order principle
Advantages of the random run order principle
Disadvantages of the random run order principle
Summary
4. Data-driven Testing
Data relevance versus data accessibility
Hardcoding input data
Hiding test data from tests
Choosing the test environment
Introducing test fixtures
Parsing fixture data
Using fixture data in the tests
Using fixtures to validate products
Testing the remaining products
Multiple test models
A single test model
Implementing multiple test models
Making test failures more expressive
Using an API as a source of fixture data
Using data stubs
The default values pattern
Advantages of the default values pattern
Disadvantages of the default values pattern
Merging the default values pattern and the faker library
Implementing faker methods
Updating the comment test to use default values
Summary
5. Stabilizing the Tests
Engineering the culture of stability
Running fast and failing fast
Running as often as possible
Keeping a clean and consistent environment
Discarding bad code changes
Maintaining a stable test suite
Waiting for AJAX
Testing without AJAX delays
Using explicit delays to test AJAX forms
Implementing intelligent delays
Waiting for JavaScript animations
The Action Wrapper pattern
Advantages of the Action Wrapper pattern
Disadvantages of the Action Wrapper pattern
Implementing the Action Wrapper pattern
The Black Hole Proxy pattern
Advantages of the Black Hole Proxy pattern
Disadvantages of the Black Hole Proxy pattern
Implementing the Black Hole Proxy pattern
Test your tests!
Summary
6. Testing the Behavior
Behavior-driven Development
Advantages of BDD
Disadvantages of BDD
Testing the shopping cart behavior
Describing shopping cart behavior
Writing step definitions
Is BDD right for my project?
Introducing Cucumber
Feature files
Step definition files
The configuration directory
Cucumber.yml
env.rb
Running the Cucumber suite
The write once, test everywhere pattern
Advantages of the write once, test everywhere pattern
Disadvantages of the write once, test everywhere pattern
Testing a mobile site
Updating the Selenium wrapper
Moving step definition files
Updating the Cucumber profile and tagging tests
Running and fixing incompatible steps
Testing the purchase API
Summary
7. The Page Objects Pattern
Understanding objects
Describing a literal object
Object properties
Object actions
Objects within objects
Describing a programming object
Describing a web page with objects
The Page Objects pattern
Advantages of the Page Objects pattern
Disadvantages of the Page Objects pattern
Creating a Page Objects framework
Creating a page super class
Implementing sidebar objects
Implementing the Sidebar...

Table of contents