Silk Mobile

Table of Contents (Homepage)

WaitForDevice

WaitForDevice(Device, Timeout)

images/images/os-icons/os_ios_150x150.png

images/images/os-icons/os_android_150x150.png

images/images/os-icons/os_windows_150x150.png

Description

The command gives the ability to choose device for testing dynamically based on query of the devices properties.

It is mandatory to release the device and make it available for other future tests, use the ReleaseDevice command.

Parameters

  • Device: Search device query.

  • Timeout: Timeout in milliseconds to wait for an available device according to the search query.

Optional properties for queries:

  • device added: if device is available on the device list in the user's machine.

  • host: IP of the host machine in the SeeTestCloud configuration.

  • location: Location of the host machine as set in the SeeTestCloud configuration.

  • manufacture

  • model

  • name

  • os: Operating system.

  • remote: If device is connected through SeeTestCloud or not (values are true/false).

  • serialnumber: S/N of the device.

  • version: The device's operating system version (for example 4.1.2).

  • versionnumber: The device's operating system version number (for example 4.1).

  • category: The device category. Currently supported in android devices. possible values- 'WATCH', 'PHONE' or 'TABLET'.

Note: If the device is in the cloud, the command will make a reservation and use the device. However, if the device is already reserved, the command will not be able to reserve the device.

Usage

Command usage: Assigns a device to a test based on a device query. The query is written in XPath syntax.

Example Queries:

  • "@added='false' and @location='US' and @manufacture='Samsung' and @os='android' and @version='4.2.2' and @remote='true'"

  • "@added='false' and @location='UK' and @manufacture='apple' and @model='iphone/ipod(3/4/5)' and @os='ios' and @remote='false' and @versionnumber='7.0'"

Code Example

UFT Example
' Get information about all available devices in XML format.
print MDriver("Driver").GetDevicesInformation
 
Dim deviceName
 
' Wait for Windows Phone cloud device (30 seconds timeout)
deviceName = MDriver("Driver").WaitForDevice ("@os='windows phone' AND @remote='true'", 30000)
print "Following device was selected: " + deviceName
 
' Perform some actions on device
MDevice("name:=" + deviceName).Open
MDevice("name:=" + deviceName).Swipe "Right", 0
wait(3)
MDevice("name:=" + deviceName).Swipe "Left", 0
 
' Release the device from cloud after using it, but do not remove from device manager.
MDriver("Driver").ReleaseDevice deviceName, false
 
' Additional examples for WaitForDevice usage
deviceName = MDriver("Driver").WaitForDevice ("@serialnumber='00000011-07ad-5c10-0000-000000000000'", 30000)
deviceName = MDriver("Driver").WaitForDevice ("@os='android'", 30000)
deviceName = MDriver("Driver").WaitForDevice ("@name='Nokia Lumia 820 (RM-825)'", 30000)