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 ...

Get Selenium Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.