ShellExecute Method

Applies to TestComplete 15.47, last modified on January 20, 2023
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

Description

Use the ShellExecute method to run shell commands on the connected Android device and get the command result. This method does the same as the adb shell command of the Android SDK.

For more information on the available shell commands, see Issuing Shell Commands in the Android developer documentation.

Declaration

AndroidDeviceObj.ShellExecute(Command)

AndroidDeviceObj An expression, variable or parameter that specifies a reference to an AndroidDevice object
Command [in]    Required    String    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Command

The shell command to run. Do not include adb shell in the command text.

Sample commands:

Command Description
logcat -d Get Android debug output.
dumpsys cpuinfo Get Android CPU information.
am start -n com.android.calculator2/.Calculator Run Calculator.

Result Value

A string containing the command output (if any).

The method also posts the command output to the Details panel of the test log.

Example

The script below runs the dumpsys cpuinfo command on the connected Android device. You will see the command output in the Details panel in the test log.

JavaScript, JScript

function Test()
{
  Mobile.SetCurrent("emulator-5554");

  // This corresponds to the "adb shell dumpsys cpuinfo" command of the Android SDK
  Mobile.Device().ShellExecute("dumpsys cpuinfo");
}

Python

def Test():
  Mobile.SetCurrent("emulator-5554")

  # This corresponds to the "adb shell dumpsys cpuinfo" command of the Android SDK
  Mobile.Device().ShellExecute("dumpsys cpuinfo")

VBScript

Sub Test
  Call Mobile.SetCurrent("emulator-5554")

  ' This corresponds to the "adb shell dumpsys cpuinfo" command of the Android SDK
  Call Mobile.Device.ShellExecute("dumpsys cpuinfo")
End Sub

DelphiScript

procedure Test;
begin
  Mobile.SetCurrent('emulator-5554');

  // This corresponds to the "adb shell dumpsys cpuinfo" command of the Android SDK
  Mobile.Device.ShellExecute('dumpsys cpuinfo');
end;

C#Script

function Test()
{
  Mobile["SetCurrent"]("emulator-5554");

  // This corresponds to the "adb shell dumpsys cpuinfo" command of the Android SDK
  Mobile["Device"]["ShellExecute"]("dumpsys cpuinfo");
}

See Also

Testing Android Applications (Legacy)
AndroidDevice Object

Highlight search results