Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active February 2, 2023 09:06
Show Gist options
  • Save eliasnogueira/61ede74ecc35fdc7b9589f07b48d9cf3 to your computer and use it in GitHub Desktop.
Save eliasnogueira/61ede74ecc35fdc7b9589f07b48d9cf3 to your computer and use it in GitHub Desktop.

Title

Parallel frontend test execution using Selenium and Docker

Description

Nowadays, the main problem regarding front-end test execution is the time spent to cover the necessary scenarios to get the proper quality feedback. It's no wonder that we are focusing more on the earlier test stages like unit and integration. But frontend tests are also important, so how to make them faster?

I could reduce 2 days of manual tests to 35min sequential tests to 6min parallel tests for the same test suite! So you also can!

We can achieve it by mixing a parallel test execution strategy with a container approach, auto-scaling its usage of it per request. Do you think it's complicated? Believe me, it's not!

The trick is done by combining three different things:

  1. a good code design, preparing it for a test parallelization using the Factory Pattern to create different driver instances based on the test requests
  2. the usage of the built-in parallel strategy from your preferred test library
  3. the usage of the Selenium 4 Grid containers, creating an orchestration to be able to auto-scale the different containers with web browsers

We will combine it all, learning how to create the necessary code with the infrastructure to speed up the front-end test execution.

Tools

  • Java 17
  • Selenium WebDriver as the frontend test automation library
  • JUnit 5 and TestNG as testing libraries, showing both the parallel approach
  • AssertJ as the assertion library
  • Docker to use the Selenium 4 Grid containers
  • Minikube to show a local k8s infrastructure for the parallel tests

Takeaways

  • Learn how to better create a Browser Factory approach
  • How to parallelize the frontend tests
  • How to use containers to auto-scale the tests, reducing the total execution time

Elevator pitch

Frontend test automation is one of the most hated ones, not because of possible flakiness, but also because of the long time to run it. People tend to solve the flakiness problems, but not the execution time to provide faster feedback. This talk will show how to speed up the test by applying a good code solution together with a container connected to a grid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment