Mobile Testing


TestingBot currently supports iOS and Android testing via Simulators and Emulators.


Currently we are working on providing real-mobile device testing, which should be launched soon.


Configuring capabilities

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


1. Select a Platform
2. Select a Device

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

caps = {
  :browserName => "%browserName%",
  :version => "%version%",
  :platform => "%platform%",
  :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 => "http://API_KEY:API_SECRET@hub.testingbot.com/wd/hub",
  :http_client => client,
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "TestingBot"
element.submit
puts driver.title
driver.quit
				
<?php
require "php-webdriver/lib/__init__.php";
	
  $capabilities = array(
  	  'browserName' => "%browserName%",
	  'version' => "%version%",
	  'platform' => "%platform%",
	  'deviceName' => "%deviceName%",
	  'platformName' => "%platformName%",
	  'name' => "My First Mobile Test"
  );
  $web_driver = RemoteWebDriver::create(
    "https://api_key:api_secret@hub.testingbot.com/wd/hub",
    $capabilities
  );
  $web_driver->get("http://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 = "http://" + 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", "%platform%");
    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("http://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%',
      'platform': '%platform%',
      '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("http://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()
				
var webdriver = require('selenium-webdriver'),
    testingbotKey = "api_key",
    testingbotSecret = "api_secret",
    driver;
 
driver = new webdriver.Builder().
  withCapabilities({
    'browserName': '%browserName%',
    'version': '%version%',
    'platform': '%platform%',
    'deviceName': '%deviceName%',
    'platformName': '%platformName%',
    'name' : 'My First Mobile Test',
    'client_key': testingbotKey,
    'client_secret': testingbotSecret
  }).
  usingServer("http://" + testingbotKey + ":" + testingbotSecret +
              "@hub.testingbot.com/wd/hub").
  build();
 
driver.get('https://www.google.com');
 
driver.getTitle().then(function (title) {
    console.log("title is: " + title);
});
 
driver.quit();



Portrait/Landscape

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


Rotate before test:
desired_capabilities = { "orientation" : "LANDSCAPE " } # or PORTRAIT

Rotate during test:
((AppiumDriver) driver).rotate(ScreenOrientation.LANDSCAPE);

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.