How to Use Selenium in Continuous Integration Testing

Selenium provides web developers with a suite of tools to automate web browsers across many platforms. At 3Pillar, we use Selenium in conjunction with continuous integration to ensure web applications are automatically tested via scripts as opposed to manually.


Before we start we will need the following installed on our local machine: Firefox (at least version 14), Java JDK (preferably the latest version: 7), Maven 3 (Maven download & setup tutorial: Maven is a tool that can now be used for building and managing any Java-based project.

Setting up a Selenium project

First we will create a folder for our Selenium project. In it we will place a pom.xml file containing the following structure:



Now open a command line console, navigate to the folder where the pom.xml is and type the following command. This will download Selenium and all the needed dependencies, and will add them to the project.

mvn clean install

Importing the project in the development environment

We will demonstrate how to import the project in Eclipse. Importing it in other IDEs is similar. Before importing, make sure you have the Maven for Eclipse plug-in installed. You can download it dirrectly from the Eclipse marketplace.

Maven for Eclipse

After this, go to File > Import. From the filters, choose Maven > Existing Maven Projects. Next, browse to the folder where our pom.xml file resides, and set it as a root directory. Eclipse should detect the project and display the pom file. Click Finish.

Maven for Eclipse Image

Now we need to create a package where our tests will be placed. The maven structure is: Make sure you stick to this naming up to the java level, or else the builder will not identify your test files.

test java

After the package is created, add src in the build path. Right click on the project name (in this example seleniumTrainingCI), choose Properties > Java Build Path. Click add and choose the src folder.

Java Build Path

First test

Create a new test class in the package. The class name must contain the word Test, or else Maven will not consider it a test class. The first test is the one presented in the documentation. The content of the java file is the following:

import static junit.framework.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestLocalRun {
  private WebDriver driver;
  private WebDriverWait wait;
  public void setUp() {
  driver = new FirefoxDriver();
  wait = new WebDriverWait(driver, 10);
  public void tearDown() throws IOException {
  public void pageTitleAfterSearchShouldBeginWithDrupal() throws IOException {
  WebElement searchField = driver.findElement("q"));
  assertTrue("The page title should start with the search string after the search.",
  wait.until(new ExpectedCondition() {
  public Boolean apply(WebDriver d) {
  return d.getTitle().toLowerCase().startsWith("drupal!");

Now let’s run this thing! Right-click anywhere in the editor window, Run As > JUnit Test. This should open a Firefox window, run the test and publish the result in Eclipse.

TestLocalRun Java Image


Creating a Git repository

Now we need a remote place to keep our stuff; we need this because for several reasons, one of them being that we want to run the code in CI. It needs to be able to download it from somewhere. This is where GitHub (or Git for short) comes in place. First you will need a Git account. It’s free to create, so go ahead. (When creating tests for the software you dev team is creating, it is probable that you will need a repository in your organization, not in your personal account. Your local IT support / teammates will help you with this).

Login and click the Create a new repo button located in the top right-hand corner. Type a title in the Repository name field, select Public (this is the only option available for the free accounts) and click Create repository.

Now we need to upload our local project folder on Github. To do this open a shell and CD to the folder where the previously created pom.xml file is located. You will need to type in the following commands, one row at a time. Replace account-name and repository-name with your Git username and the title of the repository we’ve just created online.

git init
git status
git add *
git commit -m "first commit"
git remote add origin[account-name]/[repository-name].git
git push -u origin master

Creating a CI plan

We will demonstrate how a plan is created in Bamboo, but other CI systems (ie: Jenkins) follow roughly the same steps.

Click the Create Plan button in the top right-hand corner > Create a New Plan. Choose the project where you want your plan to be created in. Type a plan name and key (only capital letters and numbers here). For Source Repository choose Git, type the Remote Repository URL (the same URL used with the git remote add command in the previous section). For Build Strategy just choose Manual for now. Click Configure Tasks.

The next step is to define a Task (the build command that will compile our source files and run the tests). Click Add Task and choolse Maven 3.x. Type a suggestive Task Description (ie: run tests). At the bottom of the page there is a section called “Where should Bamboo look for the test result files?”. Here choose Specify custom results directories; the default given location(**/target/surefire-reports/*.xml) should work. Click Save.

Maven Bamboo Task Image

On the next screen choose “Yes please!” when asked to enable the plan, and click Create. Navigate to the Project you created your plan in and open it, because there is one last configuration we need to do. In the top right corner, click Actions > Configure Plan.

Configure Build Plan Summary

Select Stages > Default Job > Requirements. Make that your build will only be triggered on machines that have all the needed capabilities. Bamboo agents need the following requirements. Your machines might need other requirements, but you get the picture.

Requirements Image

Now let’s run the build plan! Click Run > Run Plan

Run Summary Image

After the build is finished, you will see the status (Build Sumary tab) and the test results (Tests tab).

Ciprian Balea

Ciprian Balea

QA Lead

Ciprian Balea is a QA Lead who works in 3Pillar’s Timisoara, Romania office. Ciprian began his career in software testing 2 years before he graduated from college. He is proficient with Agile practices and is a Certified Scrum Master. He is most interested in the fields of Continuous Integration & Deployment, and Automation and Performance enhancements. Away from work, Ciprian likes outdoors sports and photography.

24 Responses to “How to Use Selenium in Continuous Integration Testing”
  1. Erik Yeger Scudeler on

    Hi! Nice post. But I have a question: If the Selenium tests have to run right after the build task, how can I test a web application as I have to publish the application first? I mean: Build -> Unit Tests -> QA Deployment -> Selenium Tests.


    • Ciprian Balea on

      Hi Erik. You need to create a separate plan in your CI (Bamboo used in my example) that will deploy the web application. Link the deploy plan with the test plan, so that on success the deploy plan will automatically trigger the test plan.


        There is no mention of configuring selenium or firefox from within bamboo in the specified link?? What does adding selenium and firefox as custom properties achieve?. Can you elaborate..

        • Ciprian Balea on

          When having multiple Bamboo agents (with various tools installed on them) connected to the same CI server, we need a way to differentiate between them.

          For example, out of 5 total Bamboo agents, let’s say only 3 of them have the Selenium libs installed. In this case we label the 3 machines with the “Selenium” capability from the Agents configuration panel in Bamboo. Inside the Selenium tests build plan configuration, we select the “Selenium” requirement. This will make sure our build plan only gets executed on the 3 configured agents.

  2. Marter Jay on

    Hi, Very Nice article. I tried this. But the Selenium project runs perfectly with Maven when I run it in my machine. But when I try to run it with Bamboo. It gives me an Error saying cannot access firefox.exe.
    Can you explain me why that happens. Thank you

    • Ciprian Balea on

      Marter, I would start by making sure the user Bamboo logs with on the machine has the access rights for firefox.exe.

  3. Marter Jay on

    Hi, Very Nice article. But when I try this on Bamboo, It gives me an error. But when I try the test locally it works fine. I will post the error here, Can you provide some help. Thanx.
    Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055

  4. Sarah on

    Thank you for the post, it was very helpful and detailed. I’m fresh user for Bamboo, if it is possible, I need to know how to add the Firefox & selenium requirement and more details will be good because also the admin for the bamboo server is not sure what he needs to do.

    Best regards,

  5. Akhlesh on

    very helpful article!!!

  6. John Capps on

    I can’t seem to track down the configuration for the custom capability for having Bamboo recognize selenium. I see you have it already configured but you didn’t cover how. Any tips?

    • Ciprian Balea on

      Hi John

      Indeed my Bamboo was already set up with all the need requirements, and I just needed to call them into my build plan. Please read my reply to Sarah’s question above. You can start finding the answer through the Atlassian docs.

  7. Suvranil on

    Very helpful!!
    Right now, we have only services which are ready. No UI. So how can I test the CI for those services only using Selenium and Jenkins? Please help.

    • Ciprian Balea on

      Selenium is just for testing the UI. For testing the services, you need tools and libraries specific to your product type. For example, in case you have a REST service, you can use Ruby and the “rest-client” gem.

  8. Dinesh on

    Its a nice article.
    I am using Selenium with java language for my automation testing.
    I place all my codes in TFS but not in GITHUB.
    For CI we use Microsoft release management tool . But i have no idea how to integrate Selenium (Java)code with Release management.
    Do any one has answer for this ?

    Thanks in advance

    • CJ on

      Hi, did you ever find a solution to this? I am about to start working on a .NET-based project, but using an existing Java framework.

  9. Alfonso Fuertes on

    Hello, could you give us more information about how to set up firefox and selenium like an agent in Bamboo?

    Thank you in advance.

    Best regards.

  10. David Morris on

    Hi Ciprian, great article thanks for sharing mate and hope you are well 🙂

  11. Nick on

    great article.
    Our developers have just started to use Selenium, and seem to have included the full Selenium application in their Subversion project branch.
    I would only have expected to see test cases at most in the branch, as we don’t want to include the Selenium application with our release, which is what will happen if those (1200+) files remain where they are !
    Ideally I would have expected the Selenium application to be stored outside of Subversion entirely, and although the test cases need version management, even they should be outside the actual project release area of Subversion.

    Any advice gratefully received.

  12. Saiteja on

    Hi! Thanks for your valuable information. But I have a question, Can we do integration with TestNG Test Scripts

  13. Sudhakar on

    Hello My Name is Sudhakar.
    We presently have Data Integrations in Informatica and are moving away to SSIS.
    These integrations integrate data from 2 SQL databases with both having front end applications one is Java based (source) and the target is Salesforce.
    How can we automate these integrations?? and once we automate we want it to be a part of CI.


  14. software testing on

    Nice article! I appreciate your work. whole concept about how to use selenium in continuous integration testing was explained very clearly. It’s easy to understand. The article was really very helpful for me. looking forward for article. keep posing!

Leave a Reply