Category Archives: Bamboo

Executing Selenium tests in Bamboo

In this topic, we are going to look at how we can execute Selenium tests in Bamboo.

I am assuming that you already know how to work with  Maven+JUnit, Maven+TestNG, Gradle+JUnit and Gradle+TestNG projects.

In your Selenium project, add few selenium tests as mentioned below.

A typical Selenium test project includes few test classes. Each test class extends the base class where in we define before test and after test methods. In before test method, we create the webdriver instance and also perform test initialization tasks. In after test method, we close the driver and also perform clean up tasks like closing processes created during test run.

Below is the sample base class for all Selenium Test classes.

package seleniumtests;

import org.junit.Before;
import org.junit.After;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class BaseTest {
    public WebDriver driver;
    @Before
    public void init(){
      driver = new FirefoxDriver();
    }

    @After
    public void cleanup(){
        driver.close();
        driver.quit();
    }
}

Below is the sample test class. In below test class, we have created a simple test to verify the title of website – www.softpost.org

package seleniumtests;

import org.junit.Assert;
import org.junit.Test;

public class SmokeTests extends BaseTest {

    @Test
    public void verifyTitle(){
        driver.get("http://www.softpost.org");
        Assert.assertTrue(driver.getTitle().contains("Free Software Tutorials"));
    }
}

After this, all you need to do is push this project on GitHub or your local repository server.
Then on Bamboo, you need to create maven build