Run your Selenium tests in the cloud with TestingBot

Ideally you want to run your tests in all different browsers on all platforms. It can be achieved with Selenium Grid. Setting up Selenium Grid might be an time-consuming task and you have to deal with license costs. Therefore, some companies providing cloud-based solutions.

TestingBot offers a cloud-based solution with many extra functionalities, such as: taking screenshots per command, video recording of the test execution, integrated proxy and advanced reporting.

TestingBot can be used with all kinds of programming languages. In this tutorial you will see how easy it is to run your tests in the cloud.

How to to it

  1. Create an account on TestingBot and try it for free. (or choose a sufficient plan)
  2. Download the required library from: https://github.com/testingbot
  3. Change the remote address, so the tests will be run at the remote Grid.

import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class TestingBotTest {
    private WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        DesiredCapabilities capabillities = DesiredCapabilities.firefox();
        capabillities.setCapability("version", "11");
        capabillities.setCapability("platform", Platform.WINDOWS);
        capabillities.setCapability("name", "Testing Selenium 2");

        driver = new RemoteWebDriver(
                new URL(
                        "http://ClientKey:ClientSecret@hub.testingbot.com:4444/wd/hub"),
                capabillities);
    }

    @Test
    public void testSimple() throws Exception {
        driver.get("http://selenium.polteq.com/prestashop/");
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys(
                "ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']"))
                .click();
        String searchHeader = driver.findElement(By.cssSelector("H1"))
                .getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }

    @AfterClass
    public void tearDown() throws Exception {
        driver.quit();
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class TestingBotTest {
    private WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        DesiredCapabilities capabillities = DesiredCapabilities.firefox();
        capabillities.setCapability("version", "11");
        capabillities.setCapability("platform", Platform.WINDOWS);
        capabillities.setCapability("name", "Testing Selenium 2");

        driver = new RemoteWebDriver(
                new URL(
                        "http://ClientKey:ClientSecret@hub.testingbot.com:4444/wd/hub"),
                capabillities);
    }

    @Test
    public void testSimple() throws Exception {
        driver.get("http://selenium.polteq.com/prestashop/");
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys(
                "ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']"))
                .click();
        String searchHeader = driver.findElement(By.cssSelector("H1"))
                .getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }

    @AfterClass
    public void tearDown() throws Exception {
        driver.quit();
    }
}

Additional Test Options

Screenshots

Capture screenshots at every step of the test.


capabillities.setCapability("screenshot", true);
1
capabillities.setCapability("screenshot", true);

Video

Record a video of your test, which is accessible in the member area.


capabillities.setCapability("screenrecorder", true);
1
capabillities.setCapability("screenrecorder", true);

Test Name

Add a name to this test, which will show up in our member area.


capabillities.setCapability("name", "Test Script Name");
1
capabillities.setCapability("name", "Test Script Name");

Custom data

Send along custom data, for example your build number, release, server, commit hash, etc…


capabillities.setCapability("extra", "release 1.2.3");
1
capabillities.setCapability("extra", "release 1.2.3");

Run your Selenium tests in the cloud with TestingBot
1 vote, 5.00 avg. rating (90% score)