Simulating Text Input on Android Devices (Legacy)

Applies to TestComplete 14.93, last modified on October 12, 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.

In your tests, you may need to simulate text input - keystrokes being sent to a mobile application. This topic describes how you can simulate text input on Android devices.

Note: You can use the described approach to send keystrokes both to Open and block-box mobile applications in your tests.

Simulating Text Input in Keyword Tests

To simulate text input on a mobile device in keyword tests, use the Device Keys operation. It simulates the specified keystrokes being sent to the device.

Simulating keystrokes on a mobile device

Simulating Text Input in Scripts

To simulate text input in scripts, use the Device.Keys method. The script code below demonstrates how to simulate text input on mobile devices:

JavaScript, JScript

function Test()
{

  Mobile.SetCurrent("MyDevice");
  // Performs testing actions
  // ...

  // Simulates text input on the device
  Mobile.Device().Keys("iddqd");
// ...

}

Python

def Test():

  Mobile.SetCurrent("MyDevice");
  # Performs testing actions
  # ... 

  # Simulates text input on the device
  Mobile.Device().Keys("iddqd");
  # ...

VBScript

Sub Test

  Mobile.SetCurrent("MyDevice")
  ' Performs testing actions
  ' ...

  ' Simulates text input on the device
  Mobile.Device.Keys("iddqd")
  ' ...

End Sub

DelphiScript

procedure Test();
begin

  Mobile.SetCurrent('MyDevice');
  // Performs testing actions
  // ...

  // Simulates text input on the device
  Mobile.Device.Keys('iddqd');
  // ...

end;

C++Script, C#Script

function Test()
{

  Mobile.SetCurrent("MyDevice");
  // Performs testing actions
  // ...

  // Simulates text input on the device
  Mobile.Device.Keys("iddqd");
  // ...

}

Note: To simulate text input, use TestComplete Android Agent keyboard. Otherwise, TestComplete uses a keyboard device to input the text. In this case, you cannot input local (national) symbols. For more information, see Simulating Local Symbol Input (Legacy).

When you enable the Android Agent keyboard on Android 5.1.1 or later, Android will ask for your confirmation to use the new input method. Select OK to confirm.

These actions are asynchronous. This means that TestComplete does not pause the test when they are executed. For more information, see Possible Issues.

See Also

Simulating User Actions Over Android Devices (Legacy)
Simulating Local Symbol Input (Legacy)
Simulating Text Input in Android Open Applications (Legacy)

Highlight search results