Silk Mobile

Table of Contents (Homepage)

SetDevice

SetDevice (Title)

images/images/os-icons/os_ios_150x150.png

images/images/os-icons/os_android_150x150.png

images/images/os-icons/os_windows_150x150.png

images/images/os-icons/os_blackberry_150x150.png

Description

Set the active device under test

Parameters

  • Title: Insert device name

    • For Android: Prefix 'adb:' is required ('adb:MyAndroidDevice')

    • For iOS: Prefix 'ios_app:' is required ('ios_app:MyIOSDevice')

    • For Windows Phone: Prefix 'wp:' is required ('wp:MyWindowsPhoneDevice')

Code Examples

In the following example, we will launch application Experibank on an Android device, then switch to an iOS device and launch the same application, and finally repeat these actions on a Windows Phone device:

Java Example
client.setDevice("adb:Nexus5");
client.launch("com.experitest.ExperiBank/.LoginActivity", true, true);
client.sleep(1000);
client.setDevice("ios_app:iPhone6");
client.launch("com.experitest.ExperiBank", true, true);
client.sleep(1000);
client.setDevice("wp:LumiaPhone");
client.launch("EriBank", true, true);
C# Example
client.SetDevice("adb:Nexus5");
client.Launch("com.experitest.ExperiBank/.LoginActivity", true, true);
client.Sleep(1000);
client.SetDevice("ios_app:iPhone6");
client.Launch("com.experitest.ExperiBank", true, true);
client.Sleep(1000);
client.SetDevice("wp:LumiaPhone");
client.Launch("EriBank", true, true);
VBScript Example
client.SetDevice "adb:Nexus5"
Report
client.Launch "com.experitest.ExperiBank/.LoginActivity", true, true
Report
client.Sleep 1000
Report
client.SetDevice "ios_app:iPhone6"
Report
client.Launch "com.experitest.ExperiBank", true, true
Report
client.Sleep 1000
Report
client.SetDevice "wp:LumiaPhone"
Report
client.Launch "EriBank", true, true
Report
Python Example
self.client.setDevice("adb:Nexus5")
self.client.launch("com.experitest.ExperiBank/.LoginActivity", True, True)
self.client.sleep(1000)
self.client.setDevice("ios_app:iPhone6")
self.client.launch("com.experitest.ExperiBank", True, True)
self.client.sleep(1000)
self.client.setDevice("wp:LumiaPhone")
self.client.launch("EriBank", True, True)
Perl Example
$client->setDevice("adb:Nexus5");
$client->launch("com.experitest.ExperiBank/.LoginActivity", 1, 1);
$client->sleep(1000);
$client->setDevice("ios_app:iPhone6");
$client->launch("com.experitest.ExperiBank", 1, 1);
$client->client.sleep(1000);
$client->setDevice("wp:LumiaPhone");
$client->launch("EriBank", 1, 1);