Simulating Text Input on Android Devices

Applies to TestComplete 12.60, last modified on September 17, 2018

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.

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
Simulating Local Symbol Input
Simulating Text Input in Android Open Applications

Highlight search results