Selenium DevOps series: Run your scripts in Travis CI

Aren’t you bored of running your automation scripts locally?

Madhan K
3 min readMay 16, 2020
Source — unknown

In this article, we are going to see how to run Selenium automation scripts in headless mode in the Travis CI environment. In three steps,

  1. Setup Travis CI account
  2. Add Travis YAML file
  3. Push your code

Note: Testing your open source projects are free in Travis CI

Setting up Travis CI account

  1. Head to the URL — https://travis-ci.org/
Travis CI homepage

2. Click on Sign-up and Sign-in using your GitHub account

sign-in page

3. Click on Authorize travis-ci

authorizing travis ci

4. Select the repository

select repo

5. Activate repository

activate repo

6. Builds status for the repository

build status

Now that our GitHub and Travis CI are integrated. Next step is we have to add a .travis.yml file in the same directory level

Adding .travis.yml file

.travis.yml

Adding .travis.yml file to your root folder level helps Travis CI to know how to build the project. Now let’s see what should go inside the file

dist: trusty
language: java
jdk:
- openjdk11

dist stands for distributions used to configure the version of Ubuntu

language used to configure programming language

jdk used to configure the JDK

Since we are going to run the scripts in the headless mode we don’t need to add Xvfb — the virtual framebuffer (since from Chrome 59 and Chrome 60 for Windows)

Pushing your code

Travis CI automatically recognizes that our project is built using Maven by identifying the presence of a pom.xml file. And automatically installs the dependencies.

In this i have used webdrivermanager library as one of the dependencies in pom.xml file to manage binary drivers (e.g. chromedriver, geckodriver, etc.)

settings

By default, Travis CI automatically starts build process when the code changes have been pushed or pull request has been created.

Result

The Build log shows us that our tests are passed !!!

--

--