Skip to main content

Migrate your existing tests

Migrating your existing Selenium WebDriver tests to use TestingBot is easy.
On this page, we'll show you how to modify your existing tests and run them on the browsers in our cloud.

Authentication

First, you'll need to authenticate to the TestingBot cloud.
If you haven't already, please sign up for a free trial and find your TestingBot key and secret in the member area.
You'll need to use these credentials in your test scripts to authenticate with our cloud.

Capabilities

Capabilities are used to indicate on which browsers you want to test.
You can specify a desired browser name, operating system and browser version.

For example, let's say you want to test on the latest Chrome browser on Windows 10:

options = Selenium::WebDriver::Chrome::Options.new
options.browser_version = 'latest'
options.platform_name = 'WIN10'
options.add_option('tb:options', {
  'key' => 'API_KEY',
  'secret' => 'API_SECRET',
  'name' => 'My First Test'
})
ChromeOptions options = new ChromeOptions();
options.setPlatformName("WIN10");
options.setBrowserVersion("latest");

HashMap<String, Object> tbOptions = new HashMap<>();
tbOptions.put("key", "API_KEY");
tbOptions.put("secret", "API_SECRET");
tbOptions.put("name", "My First Test");
options.setCapability("tb:options", tbOptions);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability('platformName', 'WIN10');
$capabilities->setCapability('browserVersion', 'latest');
$capabilities->setCapability('tb:options', [
    'key' => 'API_KEY',
    'secret' => 'API_SECRET',
    'name' => 'My First Test'
]);
from selenium.webdriver.chrome.options import Options

options = Options()
options.browser_version = 'latest'
options.platform_name = 'WIN10'
options.set_capability('tb:options', {
    'key': 'API_KEY',
    'secret': 'API_SECRET',
    'name': 'My First Test'
})
const chrome = require('selenium-webdriver/chrome');

let options = new chrome.Options();
options.setBrowserVersion('latest');
options.setPlatformName('WIN10');
options.set('tb:options', {
    'key': 'API_KEY',
    'secret': 'API_SECRET',
    'name': 'My First Test'
});
// for Chrome
ChromeOptions options = new ChromeOptions();

// for Firefox
// FirefoxOptions options = new FirefoxOptions();

// for Safari
// SafariOptions options = new SafariOptions();

options.PlatformName = "WIN10";
options.BrowserVersion = "latest";
options.AddAdditionalOption("tb:options", new Dictionary<string, object>
{
    ["key"] = "API_KEY",
    ["secret"] = "API_SECRET",
    ["name"] = "My First Test"
});

Running tests with Remote WebDriver

If you have been running tests on your local machine until now, then you will need to modify your test scripts to start a WebDriver session via Remote WebDriver.
Simply send the capabilities to our cloud endpoint:

https://hub.testingbot.com/wd/hub

Below is an example on how to do this:

require 'selenium-webdriver'

options = Selenium::WebDriver::Chrome::Options.new
options.browser_version = 'latest'
options.platform_name = 'WIN10'
options.add_option('tb:options', {
  'key' => 'API_KEY',
  'secret' => 'API_SECRET',
  'name' => 'My First Test'
})

driver = Selenium::WebDriver.for(:remote,
  url: 'https://hub.testingbot.com/wd/hub',
  options: options
)
driver.navigate.to 'https://www.google.com'

# Your test logic here

driver.quit
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import java.util.HashMap;

public class TestingBotSampleTest {
    public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        options.setPlatformName("WIN10");
        options.setBrowserVersion("latest");

        HashMap<String, Object> tbOptions = new HashMap<>();
        tbOptions.put("key", "API_KEY");
        tbOptions.put("secret", "API_SECRET");
        tbOptions.put("name", "My First Test");
        options.setCapability("tb:options", tbOptions);

        WebDriver driver = new RemoteWebDriver(
            new URL("https://hub.testingbot.com/wd/hub"), options
        );
        driver.get("https://www.google.com");

        // Your test logic here

        driver.quit();
    }
}
<?php
require_once('vendor/autoload.php');
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;

$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability('platformName', 'WIN10');
$capabilities->setCapability('browserVersion', 'latest');
$capabilities->setCapability('tb:options', [
    'key' => 'API_KEY',
    'secret' => 'API_SECRET',
    'name' => 'My First Test'
]);

$driver = RemoteWebDriver::create(
    'https://hub.testingbot.com/wd/hub',
    $capabilities
);

$driver->get('https://www.google.com');

// Your test logic here

$driver->quit();
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.browser_version = 'latest'
options.platform_name = 'WIN10'
options.set_capability('tb:options', {
    'key': 'API_KEY',
    'secret': 'API_SECRET',
    'name': 'My First Test'
})

driver = webdriver.Remote(
    command_executor='https://hub.testingbot.com/wd/hub',
    options=options
)

driver.get('https://www.google.com')

# Your test logic here

driver.quit()
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

async function runTest() {
    let options = new chrome.Options();
    options.setBrowserVersion('latest');
    options.setPlatformName('WIN10');
    options.set('tb:options', {
        'key': 'API_KEY',
        'secret': 'API_SECRET',
        'name': 'My First Test'
    });

    let driver = await new Builder()
        .usingServer('https://hub.testingbot.com/wd/hub')
        .setChromeOptions(options)
        .build();

    await driver.get('https://www.google.com');

    // Your test logic here

    await driver.quit();
}
runTest();
using System;
using System.Collections.Generic;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Chrome;

namespace SeleniumTest {
    class Program {
        static void Main(string[] args) {
            ChromeOptions options = new ChromeOptions();
            options.PlatformName = "WIN10";
            options.BrowserVersion = "latest";
            options.AddAdditionalOption("tb:options", new Dictionary<string, object>
            {
                ["key"] = "API_KEY",
                ["secret"] = "API_SECRET",
                ["name"] = "My First Test"
            });

            IWebDriver driver = new RemoteWebDriver(
                new Uri("https://hub.testingbot.com/wd/hub"), options
            );
            driver.Navigate().GoToUrl("https://www.google.com");

            // Your test logic here

            driver.Quit();
        }
    }
}

Migrate from one of the test frameworks

We have documentation for all the popular test frameworks.
Simply follow the documentation and examples to convert your existing tests.

If the test framework you are using is not in our documentation, please contact us and we'll be happy to help.

Test your private websites on TestingBot

TestingBot offers a feature called TestingBot Tunnel which allows you to run tests against websites hosted on your computer or private network.

Was this page helpful?

Looking for More Help?

Have questions or need more information?
You can reach us via the following channels: