Introduction to GitHub Actions CI and integration with Selenium

Afsal Backer
4 min readFeb 21, 2022

In this article, I will explain how you can to set up a Selenium project with GitHub Actions CI.

What is GitHub Actions?

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production.

Getting Started — Selenium Project

For this project, I will be using a boilerplate Selenium project code which you can clone from my GitHub repository:

( If you would like to implement this on an advanced Selenium project that uses Page object model design pattern, you can clone my sample project from my GitHub repo: . If you would like to know more about this project, you can refer to: )

First, let’s understand the platform stack ,dependencies and test code of the above boilerplate project.

Platform Stack:
Test automation tool: Selenium
Programming language: Java
Build automation tool: Maven
Test Framework: TestNG


Test Code:

This test simply opens Google search page, inputs a text and verifies search result is displayed.

Notice that I have turned on Chrome headless feature with options.addArguments(“ — headless”);
This is required as we will be running tests in headless mode in CI platforms.

In my pom.xml file, along with the dependencies, I have added the below block so that I can run test in CI using mvn command by passing the xml file name to ${suiteFile} as a parameter.



Getting Started — GitHub Actions

Once you have the project code ready, you need to create a new repository in GitHub and push the project to the new repository.

Follow the below steps to set up GitHub Actions.

  1. Open Actions

2. Select Java with Maven option from the suggested list or search and select it. Click on Configure.

3. Modify the existing yaml file as shown below

.yml explained:

  • name: Java CI with Maven
    Name of the CI job. You can modify this to any name of your liking.
  • on:push:branches [main]
    Whenever a new push is made on master branch, our GitHub action will be triggered.
  • Notice that I changed jobs:build to jobs:test. This is just to reflect the idea that we are actually running a test here rather than just building it.
  • runs-on: ubuntu-latest
    We are instructing GitHub actions to spin up a new ubuntu instance for us where we can execute our tests.
  • Steps:
    Checkout our project to the Ubuntu instance, set up JDK/Java and maven.
  • The last line is changed to run: mvn test -DsuiteFile=”testng.xml”.
    This means that I will be passing the test ‘com.example.SeleniumBoilerPlate ’ specified in ‘testng.xml’ file as a parameter to ${suiteFile} argument in pom.xml file.

4. Now click on Start commit > add a comment and > commit new file.

5. With that, our GitHub action is now live. Since we made a new push to Main branch, our job is automatically triggered. Click on Actions tab to view it.

6. Click on the workflow.

7. Click on the job ‘test’.

You can now see the steps of our Github action and it being executed one by one sequentially. Once all steps are executed, and if the test is passed, job is marked in green as you can see in the above screenshot. If it is a failure, it will be marked in red.

8. Expand ‘Build with Maven’ step to see the test results and logs

Congratulations! you just created a CI workflow for executing Selenium tests with Java and Maven.