Mobile.SetCurrent Method

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

Sets the specified device as current for the test commands working with mobile devices. Unlike TrySetCurrent, this method does not return any value and fails if an attempt to set the current device was unsuccessful.

Declaration

Mobile.SetCurrent(Name, Index)

Name [in]    Required    String    
Index [in]    Optional    Integer Default value: 1   
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Name

Specifies the name of the desired device.

Index

Specifies the zero-based index of the device in the collection of devices with the same name.

Result Value

None.

Remarks

If the specified device cannot be found or if it cannot be set as current device for mobile testing, SetCurrent fails and posts an error message to the test log.

Example

The following code example demonstrates how you can set the current device for mobile testing:

JavaScript, JScript

Mobile.SetCurrent("MyDevice", 1);

Python

Mobile.SetCurrent("MyDevice", 1)

VBScript

Call Mobile.SetCurrent("MyDevice", 1)

DelphiScript

Mobile.SetCurrent('MyDevice', 1);

C++Script, C#Script

Mobile["SetCurrent"]("MyDevice", 1);

See Also

Testing Android Applications (Legacy)
Device Method
TrySetCurrent Method

Highlight search results