PressBack Method

Applies to TestComplete 14.91, last modified on July 20, 2021
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 Back key on the device.

Declaration

AndroidDeviceObj.PressBack()

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 PressBack method to simulate pressing the Back button on a mobile device:

JavaScript, JScript

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

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

}

Python

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

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

VBScript

Sub Test

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

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

End Sub

DelphiScript

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

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

end;

C++Script, C#Script

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

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

}

See Also

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

Highlight search results