Mobile Testing

TestingBot currently supports iOS and Android testing on both simulators/emulators and Real Devices.

Configuring capabilities

Choose a device with the dropdown menus below.
We'll then show you example code, which you can use to run your own mobile tests on TestingBot.

#!/usr/bin/env ruby
require 'rubygems'
require 'selenium-webdriver'

caps = {
  :browserName => "%browserName%",
  :version => "%version%",
  :deviceName => "%deviceName%",
  :platformName => "%platformName%",
  :name => "My First Mobile Test"
}

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480

driver = Selenium::WebDriver.for(
  :remote,
  :url => "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "https://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "TestingBot"
element.submit
puts driver.title
driver.quit
<?php
require_once('vendor/autoload.php');
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;
	
  $capabilities = array(
  	  'browserName' => "%browserName%",
	  'version' => "%version%",
	  'platform' => "%platformName%",
	  'deviceName' => "%deviceName%",
	  'platformName' => "%platformName%",
	  'name' => "My First Mobile Test"
  );
  $web_driver = RemoteWebDriver::create(
    "https://api_key:api_secret@hub.testingbot.com/wd/hub",
    $capabilities, 240000
  );
  $web_driver->get("https://google.com");

  $element = $web_driver->findElement(WebDriverBy::name("q"));
  if($element) {
      $element->sendKeys("TestingBot");
      $element->submit();
  }
  print $web_driver->getTitle();
  $web_driver->quit();
?>
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;

public class JavaSample {

  public static final String KEY = "KEY";
  public static final String SECRET = "SECRET";
  public static final String URL = "https://" + KEY + ":" + SECRET + "@hub.testingbot.com/wd/hub";

  public static void main(String[] args) throws Exception {

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "%browserName%");
    caps.setCapability("version", "%version%");
    caps.setCapability("platform", "%platformName%");
    caps.setCapability("deviceName", "%deviceName%");
    caps.setCapability("platformName", "%platformName%");
    caps.setCapability("name", "My First Mobile Test");

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
    driver.get("https://www.google.com/ncr");
    WebElement element = driver.findElement(By.name("q"));

    element.sendKeys("TestingBot");
    element.submit();

    System.out.println(driver.getTitle());
    driver.quit();

  }
}
import unittest
import sys

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from testingbotclient import TestingBotClient

class TestTestingBotClient(unittest.TestCase):

    def setUp(self):
		desired_cap = {
		  'browserName': '%browserName%',
		  'version': '%version%',
		  'deviceName': '%deviceName%',
		  'platformName': '%platformName%',
		  'name' : 'My First Mobile Test',
		}

		self.driver = webdriver.Remote(
		    command_executor='http://key:secret@hub.testingbot.com/wd/hub',
		    desired_capabilities=desired_cap)

    def test_google_example(self):
		self.driver.get("https://www.google.com")
		if not "Google" in self.driver.title:
		    raise Exception("Unable to load google page!")
		elem = self.driver.find_element_by_name("q")
		elem.send_keys("TestingBot")
		elem.submit()

    def tearDown(self):
		self.driver.quit()
		status = sys.exc_info() == (None, None, None)
		tb_client = TestingBotClient('key', 'secret')
		tb_client.tests.update_test(self.driver.session_id, self._testMethodName, status)

if __name__ == '__main__':
    unittest.main()
const wd = require('wd'),
testingbotKey = "api_key",
testingbotSecret = "api_secret"
 
desiredCaps = {
    'browserName': '%browserName%',
    'version': '%version%',
    'deviceName': '%deviceName%',
    'platformName': '%platformName%',
    'name' : 'My First Mobile Test'
}

driver = wd.remote("https://" + testingbotKey + ":" + testingbotSecret + "@" + "hub.testingbot.com/wd/hub")
driver.init(desiredCaps, function() {
  driver.get('https://www.google.com', function() {
    driver.title(function(err, title) {
        console.log(title)
        driver.quit()
    })
  })
})

Portrait/Landscape

It's possible to rotate the device before and during your test. Please see these examples:

Rotate before test (iOS only):
desired_capabilities = { "orientation" : "LANDSCAPE " } # or PORTRAIT
Rotate during test:
((AppiumDriver) driver).rotate(ScreenOrientation.LANDSCAPE);

Specifying Appium Version

TestingBot will use the most recent, compatible, Appium version according to the device, OS and version you specify.

If you'd like to specify your own Appium version, you can do this with the appiumVersion capability.

caps = {
  platformName: "iOS",
  deviceName: "iPhone 15",
  browserVersion: "17.4",
  browserName: 'safari',
  "tb:options" => {
    "appiumVersion" : "2.4.1"
  }
}
ChromeOptions chromeOpts = new ChromeOptions();
chromeOpts.setExperimentalOption("w3c", true);

MutableCapabilities tbOptions = new MutableCapabilities();
tbOptions.setCapability("key", "api_key");
tbOptions.setCapability("secret", "api_secret");
tbOptions.setCapability("appiumVersion", "2.4.1");

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("platformName", "iOS");
caps.setCapability("tb:options", tbOptions);
caps.setCapability("deviceName", "iPhone 16");
caps.setCapability("browserVersion", "18.6");
caps.setCapability("browserName", "safari");
$options = new ChromeOptions();
$capabilities = DesiredCapabilities::safari();
$capabilities->setPlatform('iOS');
$capabilities->setCapability('tb:options', array(
	'appiumVersion' => "2.4.1"
));
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
tbOptions = {
	'name': 'W3C Sample',
	'appiumVersion': "2.4.1"
}

chromeOpts =  {
    'browserName': "safari",
    'platformName': "iOS",
    'browserVersion': "18.6",
    'deviceName': "iPhone 16",
    'goog:chromeOptions': {'w3c': True},
    'tb:options': tbOptions
}

self.driver = webdriver.Remote(remote_url, desired_capabilities=chromeOpts)
driver = await new webdriver.Builder().withCapabilities({
    "browserName": 'safari',
    "platformName": 'iOS',
    "deviceName": 'iPhone 16',
    "browserVersion": '18.6',

    /** Google requires "w3c" to be set in "goog:chromeOptions" as true if you're using ChromeDriver version 74 or lower.
     * Based on this commit: https://chromium.googlesource.com/chromium/src/+/2b49880e2481658e0702fd6fe494859bca52b39c
     * ChromeDriver now uses w3c by default from version 75+ so setting this option will no longer be a requirement **/
    "goog:chromeOptions" : { "w3c" : true },
    "tb:options": {
        "key": "api_key",
        "secret": "api_secret",
        "appiumVersion": "2.4.1"
    }
}).usingServer("https://hub.testingbot.com/wd/hub").build();
var chromeOptions = new ChromeOptions()
{
    BrowserVersion = "18.6",
    PlatformName = "iOS",
    DeviceName = "iPhone 16",
    BrowserName = "safari",
    UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
    ["key"] = "api_key",
    ["secret"] = "api_secret",
    ["appiumVersion"] = "2.4.1"
};

chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);

driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
    chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));

Testing Internal/Staged Websites

We've built TestingBot Tunnel, to provide you with a secure way to run tests against your staged/internal webapps.

Please see our TestingBot Tunnel documentation for more information about this easy to use tunneling solution.

Was this page helpful?

Looking for More Help?

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