Automated GUI Testing: How to Get It Right

That said, automation is critical to:

  1. Empower human testers to uncover more complex issues
  2. Help cover quality for existing functionality
  3. Provide constant, steady feedback on quality and performance

One of the trickiest aspects of any software to automate is graphical user interface (GUI) testing. That’s because user behavior is complex. The complexity of automating GUI test cases can lead QA teams to have to constantly update their scripts, not automate enough (and not the reap the benefits above) or to create overly simplistic automated scripts that aren’t valuable.

These tips will help you combat the complexity of GUI automated testing without forsaking value.

1. Remove system functionality from GUI testing

First thing’s first: remove anything from GUI testing that isn’t actually GUI testing.

Any automated test whose script refers to the names of fields and buttons could need to be rewritten when those fields and buttons are renamed.

Clint Hoagland

One way to bypass the complications of GUI testing is to not use GUI elements in the test scripts whatsoever. Program reasonable tests with context and expected results using back-end functions directly, instead of calling upon those functions in the way that a user would.

2. Use abstractions

An easy example of this is a file upload.

Here is a problematic script:

On the Media Library page, click the button called “New Upload”

Select the file “test.pdf”

Click the button called “Upload”

In the field called “Title” enter “My Test PDF”

In the field called “Description” enter “Single page PDF”

In this script, we’re detailing the process of the upload, meaning that if the process of the app or website changes, then this script (and countless others) need to change as well.

But we can rewrite this script to be less susceptible to change by abstracting those details:

On the Media Library page, upload “test.pdf”

On the File Details page, use the “Title” of “My Test PDF” and the “Description” of “Single page PDF”

When refactoring your scripts to include more abstractions and fewer details, first ask yourself whether that step needs to be rewritten or removed. For example, you don’t want to include the login process in every single script, but only in the appropriate cases where logging in needs to be thoroughly tested.

3. Learn from manual testing

  1. The task to be performed
  2. The related data needed to perform the task
  3. The expected result

Using the upload example again, the task would be uploading a file; the related data would be the PDF file, and the expected result would be that the upload is allowed.

A test doesn’t have to include how to get to there—meaning how to get to the upload feature in the first place.

The manual tester checks that they are in the right product area, decides how to perform a task, makes sure the environment and context are in place, and checks for the expected result.

A high-quality GUI script should be a singular event that begins with being in the right place. So rather than navigating us through an app to the right place, a script might simply begin with On the “Account Settings” Page. 

4. Rely on the right tools

Choosing the right automation tools is critical to increasing the likelihood of ROI. Any automation project should be treated like a software development project, meaning it is going to be continually reiterated upon. Automation is an active, ongoing process. So, you’ll want to choose an automation suite that works with you and your team.

At the very least, you’ll want to check for these factors:

  • Easy to learn: has syntax and classes that are intuitive and don’t require complex coding so that with any organizational changes or team member handovers, the suite can be maintained
  • Simple commands: with GUI automated testing especially, you’ll want a small set of simple commands (things like click and scroll up) to use when writing scripts so that the language used is forcibly standardized and stable
  • Recording: to automatically write test scripts, you’ll want to choose a GUI testing tool that will record your actions and generate a script using object recognition (rather than record low-level events or rely on visuals), allowing you to review, modify, save and rerun the test
  • Integrations: the biggest challenge with test automation is making use of the results, and to combat this you’ll want the tool to integrate with your existing bug tracking system in a way that you will respect and trust—not overwhelm your system with low quality, repetitive bugs

Automating GUI tests can provide continuous feedback on the user’s environment, verification of performance and functionality and comparison of repetitive test results. With the visual nature of GUI and the need for continual design improvements, the benefits of GUI automation testing can be easily overwhelmed by its fluidity. By streamlining scripts, you can protect their longevity and free up time for other quality enhancement projects.

Jumbotron image