PressHome Method

Applies to TestComplete 15.62, last modified on March 19, 2024
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

Simulates pressing the Home key on the device.

Declaration

AndroidDeviceObj.PressHome()

AndroidDeviceObj An expression, variable or parameter that specifies a reference to an AndroidDevice object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

To record this method, press the appropriate emulated button in the Mobile Screen window of TestComplete.

Example

The example below demonstrates how to use the PressHome method to simulate pressing the Home button on a mobile device:

JavaScript, JScript

function Test()
{
  // Specify the current device
  Mobile.SetCurrent("MyDevice");

  // Simulate user actions
  …
  Mobile.Device().PressHome();
  …

}

Python

def Test():
  # Specify the current device
  Mobile.SetCurrent("MyDevice")

  # Simulate user actions
  # ...
  Mobile.Device().PressHome()
  # ...

VBScript

Sub Test

  ' Specify the current device
  Call Mobile.SetCurrent("MyDevice")

  ' Simulate user actions
  …
  Call Mobile.Device.PressHome()
  …

End Sub

DelphiScript

procedure Test;
begin
  // Specify the current device
  Mobile.SetCurrent('MyDevice');

  // Simulate user actions
  …
  Mobile.Device.PressHome();
  …

end;

C++Script, C#Script

function Test()
{
  // Specify the current device
  Mobile["SetCurrent"]("MyDevice");

  // Simulate user actions
  …
  Mobile["Device"]["PressHome"]();
  …

}

See Also

Testing Android Applications (Legacy)
AndroidDevice Object
Simulating Physical Button Events (Legacy)

Highlight search results