#37: Reliable Client Booking Test
A complete, easy to read and maintain test script.
This is an enhancement exercise of the previous two exercises, to create a production-quality automated test script for this core business scenario for WhenWise.
Learning Objectives
The concept of dynamic test data
When a manual tester performs “Clicking on tomorrow’s date”, a dynamic test data, they can choose it without thinking. In test automation, we have to ‘think’ as ‘robots’,
- Get today’s date
- Get tomorrow’s date
- Get the specific format of tomorrow’s date as requiredReview
- Usingtext()
in XPath
- RefactoringNaming of Modal Page Class
Test Design
The steps are the same as before, mainly two enhancement tasks.
Don’t use hard-coded tomorrow’s day, make it dynamic.
It is common that we focus on getting test steps working at the first go, with some rough edges to be refine later. But be sure to do that after you get first successful run, which meant the core test steps are fine only.
However, there are many other factors, such as “Will this test run OK again?”, “Will this test run next week?”, “It is relatively immune to common changes”, … , etc. Make a habit to stabilise and refine the test scripts immediately. For example, the hard-coded date in the previous exercises means the test script works for that day only. Make it dynamic.
Check out the article, Working Automated Test ≠ Good Reliable Test.Refactoring
For longer test script, it is even more important to refactor as you go. This will help keep your mind clear and debugging test scripts easier.
The most common refactoring is “Extract to Page Function”.
Tasks
Task 1. Get a dynamic date for booking, e.g. tomorrow
Thanks to the brilliant ActiveSupport library in Ruby, generating a dynamic date is easy.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.