Book Image

Selenium Design Patterns and Best Practices

By : Dima Kovalenko
Book Image

Selenium Design Patterns and Best Practices

By: Dima Kovalenko

Overview of this book

Table of Contents (18 chapters)
Selenium Design Patterns and Best Practices
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The default values pattern


Filling out form information is one of the core principles of writing tests with Selenium. The test will need to register a new user, or make a purchase, or log in to an account at some point. The default values pattern aims to extract any data that our test does not actually care about. Tests should not have to know what the username and password are for every test user on every environment we have. Instead, it should rely on defaults that are appropriate for the current state.

Advantages of the default values pattern

Isolating irrelevant data from the test implementation has many advantages:

  • Need to know basis: If our test is testing whether a purchase can be made with a credit card, the test does not need to know which credit card was used. However, if our test needs to check whether a certain credit card is accepted, then the card number is known to the test.

  • Simpler tests: Extracting all of the unnecessary data out of the test implementation makes the test easier...