Five steps to successfully learn any test automation framework

Being a lifelong learner, I jump at any excuse to learn a new piece of software. No matter if it’s a development tool, test automation framework, or a new utility program. If it has the potential to enhance my current abilities and optimise my workflow. Then I need to investigate it.

I recently started a new web-based project and needed something to perform UI testing. After evaluating my options (similar to the process outlined here). I decided to use the JavaScript E2E framework, Cypress. Which hasn’t been something that I’ve consistently been using, but since it now supports browsers other than Chrome. It fits my needs perfectly.

When learning a new piece of technology. I like to follow a set list of tasks which are designed to build up my knowledge base and enable me to progress with confidence as I dive deeper into the advanced features on offer. I have taken this step-by-step process and adapted it to the context of learning test automation frameworks. And since I’m going through this process myself at the moment. I hope sharing the strategy I’m following is useful for anyone reading.

Start with the basics

When I say the basics. I mean the VERY basics.

You may already be comfortable in a programming language and know the fundamentals like declaring variables and the process of decision-making in your programs. But as the saying goes, you need to walk before you can run.

Take some time to become familiar with the fundamentals of a new tool. Knowing how to navigate pages, perform requests and interact with UI elements are the buildings blocks that will form the basis of your knowledge as you move forward. Taking the time to invest in building up this knowledge from your initial interaction will decrease the risk of running into errors later on.

Don’t worry about repeating yourself initially. But don’t make a habit of it

Here are the instructions for making a cup of tea (written in pseudo-code).

Kettle.FillUp(Water)
Kettle.HeatUp
Cup.GetOut
Cup.PutIn(TeaBag)
Cup.PutIn(Sugar)
Cup.PutIn(HotWater)
Cup.PutIn(Milk)
Cup.Stir

When you are learning something new, be it a tool, a new skill, or an unfamiliar concept or idea. The most important thing is to use the new ‘thing’ in a practical, real-life scenario as quickly as possible. You could spend hours, days, or even longer watching tutorials on how best to use it. But until you do something with the knowledge. It’s just theory.

So with that said. The code above is OK for our purposes. It might not be great code considering the number of lines it is and it not being reusable (what if we wanted to make x number of cups?). But that’s what refactoring is for. Remember, we are still learning and there is no need to worry about doing things ‘the best way’ first time. Just worry about getting the result you need.

Incorporate design patterns like page objects and custom functions

Frameworks built with tools like Selenium often make use of what is referred to as a page object. This encapsulates all of a page’s elements and the functions needed to interact with them. Cypress can be customised to work with page objects as well. But it’s highly recommended that you make use of the built-in custom commands feature instead.

So taking our cup of tea example from the previous step. Recreated in a single page object would look something like this:

Class MakeTea:

def FreshCup(Water, TeaBag, Sugar, Milk):
  
  kettle = new Kettle()
  cup = new Cup()
  
  kettle.FillUp(Water)
  kettle.HeatUp(Water)
  cup.GetOut
  cup.PutIn(TeaBag)
  cup.PutIn(Sugar)
  cup.PutIn(Water)
  cup.PutIn(Milk)
  cup.Stir

  return cup.contents

Then we could call it in our tests by calling:

def test_MakeTea():
  cupoftea = MakeTea()
  tea = cupoftea.FreshCup(Water, TeaBag, Sugar, Milk)

With this pattern, I can call my .FreshCup method whenever I need to make a fresh cup of tea instead of repeating the entire series of steps every time.

This not only increases readability for anyone who needs to understand our automated tests. But it also much cleaner and better way to organise our code.

If you want to view the page object pattern in a real-world scenario, then I have a Selenium Framework written in C# on my GitHub which you can refer to. Also, feel free to message me on LinkedIn if you have questions on this pattern.

Experiment with advanced features

Let’s use the example of a failed test case. You may want your framework to capture a screenshot of a failed test case to make debugging a little easier. If you are using Selenium, I recommend a utility called Shutterbug to achieve this (though you can do it programmatically if you wish). Cypress has a screenshot taking feature built-in, and other frameworks are available.

Other features you may want to consider adding are:

  • Logging (Very important!)
  • Work with remote browser tools (Like Browser Stack and Sauce Labs).
  • The ability to use multiple browsers.

Build on what you’ve learned and create an open source project

Pick a website or any application that you can find on the internet today. It might be Reddit, Twitter or the BBC home page. Taking the time to put into practise everything that you have learned will not only consolidate your learning and reaffirm that you can use the technology. But the process of ‘putting it out there’ and receiving feedback from other people will increase your confidence 100x and enable you to get valuable feedback.

Make sure you host it on GitHub and tweet me to let me know. I’d love to see anything that you make!

Bonus tip: Never make the mistake of considering yourself ‘done with learning’

Once you’ve made one or two practise projects. Or even some frameworks to fulfil real-world requirements. You might be tempted to feel that you’ve now learned all there is to know about a tool or utility. And while you may know what you need to be productive and make what you need. The view of your knowledge being ‘complete’ in an area is a dangerous fallacy.

The web is constantly growing with fresh ways to build websites and unique ways to interact with their content being released all the time. The best automation developers I know never consider themselves ‘done’. They realise that the knowledge that they have only fills up a tiny fraction of everything there is to know.

From different locator strategies and invoking on-page elements. To dealing with HTML5 content and iframes. There is a lot to learn, a lot of knowledge to gain, and a lot of variety in what each website and application has to offer.

I hope this was useful to you. Let me know in the comments what your learning process looks like and what you’re currently learning.

Posted by Kevin Tuck

Kevin Tuck is an ISTQB qualified software tester with nearly a decade of professional experience. Well versed in creating versatile and effective testing strategies. He offers a variety of collaborative software testing services. From managing your testing strategy, creating valuable automation assets, or serving as an additional resource.

One Reply to “Five steps to successfully learn any test automation framework”

  1. […] Five steps to successfully learn any test automation framework Written by: Kevin Tuck […]

    Reply

Leave a Reply