PressBack Method

Applies to TestComplete 14.72, last modified on January 20, 2021

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
AndroidDevice Object
Simulating Physical Button Events

Highlight search results