Mobile App Options
Please see the examples below on how to customize your test run on our mobile emulators and devices.
Appium Options
Appium provides a lot of options to configure your test.
Some important options that might help:
For Android:- appActivity and appPackage: by default, Appium will try to extract the main Activity from your apk. If this fails, you can supply your own with these options.
- chromeOptions: additional chromedriver options you can supply.
- otherApps: a JSON array of other apps that need to be installed, in URL format.
- locale: the language of the simulator/device (ex: fr_CA)
- newCommandTimeout: How long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session
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.
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.0");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("platformName", "iOS");
caps.setCapability("tb:options", tbOptions);
caps.setCapability("deviceName", "iPhone 13");
caps.setCapability("browserVersion", "16.0");
caps.setCapability("browserName", "safari");
tbOptions = {
'name': 'W3C Sample',
'appiumVersion': "2.0"
}
chromeOpts = {
'browserName': "safari",
'platformName': "iOS",
'browserVersion': "16.0",
'deviceName': "iPhone 13",
'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 13',
"browserVersion": '16.0',
/** 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.0"
}
}).usingServer("https://hub.testingbot.com/wd/hub").build();
var chromeOptions = new ChromeOptions()
{
BrowserVersion = "16.0",
PlatformName = "iOS",
DeviceName = "iPhone 13",
BrowserName = "safari",
UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
["key"] = "api_key",
["secret"] = "api_secret",
["appiumVersion"] = "2.0"
};
chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);
driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));
Appium 2 Versions
We currently support these Appium 2 versions:
- 2.0.0-beta.55
- 2.0.0-beta.44
Throttle Network
TestingBot provides a throttle network feature, which will simulate specific network conditions during a test.
We offer various presets:
-
Edge:
- 250kbps download
- 150kbps upload
- 0% Loss
- 300ms Latency
-
3G:
- 400kbps download
- 100kbps upload
- 0% Loss
- 100ms Latency
-
4G:
- 18000kbps download
- 9000kbps upload
- 0% Loss
- 100ms Latency
-
airplane:
Simulates Airplane Mode (no network connectivity)
-
disable:
Revert the throttling to no throttling.
We also offer the possibility to specify your own download
, upload
, loss
and latency
values.
You can pass a preset or specific options at the start of your test (through the capabilities
), or during the test (with execute_script
).
ChromeOptions chromeOpts = new ChromeOptions();
chromeOpts.setExperimentalOption("w3c", true);
MutableCapabilities tbOptions = new MutableCapabilities();
tbOptions.setCapability("key", "api_key");
tbOptions.setCapability("secret", "api_secret");
tbOptions.setCapability("throttle_network", "3G");
MutableCapabilities throttleOptions = new MutableCapabilities();
throttleOptions.setCapability("uploadSpeed", 10 * 1024);
throttleOptions.setCapability("downloadSpeed", 10 * 1024);
throttleOptions.setCapability("latency", 0);
throttleOptions.setCapability("loss", 0);
tbOptions.setCapability("throttle_network", throttleOptions);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("tb:options", tbOptions);
caps.setCapability("browserName", "chrome");
$options = new ChromeOptions();
$capabilities = DesiredCapabilities::chrome();
$capabilities->setPlatform('Windows 10');
$capabilities->setCapability('tb:options', array(
'selenium-version' => '2.53.1',
'throttle_network' => '3G',
'throttle_network' => array(
'uploadSpeed' => 10 * 1024,
'downloadSpeed' => 10 * 1024,
'latency' => 0,
'loss' => 0
)
));
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
tbOptions = {
'name': 'W3C Sample',
'throttle_network': '3G',
'throttle_network': {
'uploadSpeed': 10 * 1024,
'downloadSpeed': 10 * 1024,
'latency': 0,
'loss': 0
}
}
chromeOpts = {
'browserName': "chrome",
'goog:chromeOptions': {'w3c': True},
'tb:options': tbOptions
}
self.driver = webdriver.Remote(remote_url, desired_capabilities=chromeOpts)
driver = await new webdriver.Builder().withCapabilities({
"browserName": 'chrome',
/** 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",
"throttle_network": "3G",
"throttle_network": {
"uploadSpeed": 10 * 1024,
"downloadSpeed": 10 * 1024,
"latency": 0,
"loss": 0
}
}
}).usingServer("https://hub.testingbot.com/wd/hub").build();
var chromeOptions = new ChromeOptions()
{
BrowserVersion = "latest",
PlatformName = "Windows 10",
UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
["key"] = "api_key",
["secret"] = "api_secret",
["name"] = TestContext.CurrentContext.Test.Name,
["throttle_network"] = "3G"
};
chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);
driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));
((JavascriptExecutor) driver).executeScript("tb:throttle", "3G");
// or
Map<String, Object> throttleMap = new HashMap<>();
throttleMap.put("downloadSpeed", 10 * 1024);
throttleMap.put("uploadSpeed", 10 * 1024);
throttleMap.put("latency", 0);
throttleMap.put("loss", 0);
((JavascriptExecutor) driver).executeScript("tb:throttle", throttleMap);
To stop network throttling during your test, pass
disable: true
in thetb:throttle
options via theexecute_script
.
Device Name
When running a mobile automated test, you'll need to specify on which mobile device (or simulator/emulator) you want to test.
ChromeOptions chromeOpts = new ChromeOptions();
chromeOpts.setExperimentalOption("w3c", true);
MutableCapabilities tbOptions = new MutableCapabilities();
tbOptions.setCapability("key", "api_key");
tbOptions.setCapability("secret", "api_secret");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("platformName", "Android");
caps.setCapability("tb:options", tbOptions);
caps.setCapability("deviceName", "Samsung S21");
var chromeOptions = new ChromeOptions()
{
PlatformName = "Android",
UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
["key"] = "api_key",
["secret"] = "api_secret",
["name"] = TestContext.CurrentContext.Test.Name,
["deviceName"] = "Samsung S21"
};
chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);
driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));
We offer special parameters which you can use to allocate a device:
Regex Input | Result |
---|---|
"iPhone.*" |
This will allocate any available iPhone device (phone) |
".*Galaxy.*" |
This will allocate any of the available Galaxy devices (phone or tablet) |
"*" |
This will allocate a random available device, either iOS or Android device |
"iPhone [8-11]" |
This will allocate either an iPhone 8 or 11 |
"iPhone 6.*" |
This will allocate either an iPhone 6 or 6S |
Some Examples:
Tablet Only
You can specify this capability when you only want to allocate a tablet device.
ChromeOptions chromeOpts = new ChromeOptions();
chromeOpts.setExperimentalOption("w3c", true);
MutableCapabilities tbOptions = new MutableCapabilities();
tbOptions.setCapability("key", "api_key");
tbOptions.setCapability("secret", "api_secret");
tbOptions.setCapability("tabletOnly", true);
tbOptions.setCapability("deviceName", "*");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("platformName", "Android");
caps.setCapability("tb:options", tbOptions);
driver = await new webdriver.Builder().withCapabilities({
"browserName": 'chrome',
"deviceName": '*',
"platformName": 'Android',
"goog:chromeOptions" : { "w3c" : true },
"tb:options": {
"key": "api_key",
"secret": "api_secret",
"tabletOnly": true
}
}).usingServer("https://hub.testingbot.com/wd/hub").build();
var chromeOptions = new ChromeOptions()
{
PlatformName = "Android",
UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
["key"] = "api_key",
["secret"] = "api_secret",
["name"] = TestContext.CurrentContext.Test.Name,
["deviceName"] = "*",
["tabletOnly"] = true
};
chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);
driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));
Phone Only
You can specify this capability when you only want to allocate a phone device.
ChromeOptions chromeOpts = new ChromeOptions();
chromeOpts.setExperimentalOption("w3c", true);
MutableCapabilities tbOptions = new MutableCapabilities();
tbOptions.setCapability("key", "api_key");
tbOptions.setCapability("secret", "api_secret");
tbOptions.setCapability("phoneOnly", true);
tbOptions.setCapability("deviceName", "*");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ChromeOptions.CAPABILITY, chromeOpts);
caps.setCapability("platformName", "Android");
caps.setCapability("tb:options", tbOptions);
driver = await new webdriver.Builder().withCapabilities({
"browserName": 'chrome',
"deviceName": '*',
"platformName": 'Android',
"goog:chromeOptions" : { "w3c" : true },
"tb:options": {
"key": "api_key",
"secret": "api_secret",
"phoneOnly": true
}
}).usingServer("https://hub.testingbot.com/wd/hub").build();
var chromeOptions = new ChromeOptions()
{
PlatformName = "Android",
UseSpecCompliantProtocol = true
};
var tbOptions = new Dictionary<string, object>
{
["key"] = "api_key",
["secret"] = "api_secret",
["name"] = TestContext.CurrentContext.Test.Name,
["deviceName"] = "*",
["phoneOnly"] = true
};
chromeOptions.AddAdditionalCapability("tb:options", tbOptions, true);
driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(600));