Mobile.ConnectDevice Method

Applies to TestComplete 15.63, last modified on April 10, 2024


Connects to the specified mobile device and opens a testing session on it. The target testing session will match the specified desired capabilities.


Mobile.ConnectDevice(HubUrl, Capabilities, ConnectTimeoutSec)

HubUrl [in]    Required    String    
Capabilities [in]    Required    Object    
ConnectTimeoutSec [in]    Optional    Integer Default value: 180   
Result A Device object

Applies To

The method is applied to the following object:


The method has the following parameters:


Specifies the URL of the server that manages the target mobile device. It can be either the BitBar hub or an Appium server running on your local computer or on a remote computer in your local network.


The object that describes a testing session you want to open on your mobile device. For the list of required capabilities, see Supported capabilities.


Specifies the period (in seconds) for which the method waits for the session to open. If the parameter is not specified, the default value (180 seconds) will be used.

Result Value

The Device object that provides access to the mobile device (a real device or an emulator) on which the session is opened.

Note: All further method calls with the same capabilities will not reconnect to the specified device. The method will return the same Device object and reset the state of the tested application on it.


The following code sample shows how to connect to an Appium server and to open a testing session on an Android device:


function Connect_Android_Appium()
  var server = "http://localhost:4723/wd/hub"; // or "http://localhost:4723/" for older versions
  var capabilities = {
    deviceName: "MyAndroidDevice",
    platformVersion: 10,
    platformName: "android",
    automationName: "UIAutomator2",
    app: "/tests/MyApp.apk",
    newCommandTimeout: 600

  Mobile.ConnectDevice(server, capabilities);



def Connect_Android_Appium():
  server = "http://localhost:4723/wd/hub" # or "http://localhost:4723/" for older versions
  capabilities = {
    "deviceName": "MyAndroidDevice",
    "platformVersion": 10,
    "platformName": "android",
    "automationName": "UIAutomator2",
    "app": "/tests/MyApp.apk",
    "newCommandTimeout": 600

  Mobile.ConnectDevice(server, capabilities)


Sub Connect_Android_Appium()
  server = "http://localhost:4723/wd/hub" // or "http://localhost:4723/" for older versions
  capabilities = "{""deviceName"":""MyAndroidDevice"",""platformVersion"":10,""platformName"":""android"",""automationName"":""UIAutomator2"",""app"":""\/tests\/MyApp.apk"",""newCommandTimeout"":600}"
  Call Mobile.ConnectDevice(server, capabilities)

End Sub


procedure Connect_Android_Appium();
var server, capabilities;
  server := 'http://localhost:4723/wd/hub'; // or "http://localhost:4723/" for older versions
  capabilities := '{"deviceName":"MyAndroidDevice","platformVersion":10,"platformName":"android","automationName":"UIAutomator2","app":"\/tests\/MyApp.apk","newCommandTimeout":600}';

  Mobile.ConnectDevice(server, capabilities);

C++Script, C#Script

function Connect_Android_Appium()
  var server = "http://localhost:4723/wd/hub"; // or "http://localhost:4723/" for older versions
  var capabilities = "{\"deviceName\":\"MyAndroidDevice\",\"platformVersion\":10,\"platformName\":\"android\",\"automationName\":\"UIAutomator2\",\"app\":\"\\/tests\\/MyApp.apk\",\"newCommandTimeout\":600}";
  Mobile["ConnectDevice"](server, capabilities);


See Also

Mobile Object
Disconnect Method
Connecting to Mobile Devices and Opening Testing Sessions
Run Remote Device Operation

Highlight search results