Working With AutoCompleteTextView

Applies to TestComplete 15.63, last modified on April 10, 2024
Working With Generated ListView

When hints are displayed by the AutoCompleteTextView object, the application creates the List View with items containing the provided hints. You can work with this control in the same way as with any other list view control.

The generated List View is the child object of the application process, not AutoCompleteTextView.
Defining the Hint Threshold

You can define the minimum number of symbols needed to activate the hint. To do this, use the native android mThreshold field. The drop-down list is shown when the number of letters in text view equals the mThreshold value. The following example gets the mThreshold value and posts it to the log:

JavaScript, JScript

function Test()
{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");

  // Obtain AutoCompleteTextView
  var p = Mobile.Device().Process("com.example.myapp");
  var AutoText = p.RootLayout("").Layout("layoutTop").Layout("layout3").Layout("layout4").AutoCompleteTextView("edit7");
  
  // Get the Threshold value
  var Threshold = AutoText.mThreshold;
  
  // Post the value to the log
  Log.Message(Threshold);
}

Python

def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")

  # Obtain AutoCompleteTextView
  p = Mobile.Device().Process("com.example.myapp")
  AutoText = p.RootLayout("").Layout("layoutTop").Layout("layout3").Layout("layout4").AutoCompleteTextView("edit7")
  
  # Get the Threshold value
  Threshold = AutoText.mThreshold
  
  # Post the value to the log
  Log.Message(Threshold)

VBScript

Sub Test()
  ' Select the Android device
  Call Mobile.SetCurrent("MyDevice")

  ' Obtain EditText and fill it with text
  Set p = Mobile.Device.Process("com.example.myapp")
  Set AutoText = p.RootLayout("").Layout("layoutTop").Layout("layout3").Layout("layout4").AutoCompleteTextView("edit7")
  
  ' Get the text of the control
  Threshold = AutoText.mThreshold
  
  ' Post the text to the log
  Log.Message(Threshold)
End Sub

DelphiScript

function Test();
var
  p, AutoText, Threshold : OleVariant;
begin 
  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain AutoCompleteTextView
  p := Mobile.Device.Process('com.example.myapp');
  AutoText := p.RootLayout('').Layout('layoutTop').Layout('layout3').Layout('layout4').AutoCompleteTextView('edit7');
  
  // Enter part of the text
  Threshold := AutoText.mThreshold;
  
  // Select the item of the ListView
  Log.Message(Threshold);
end;

C++Script, C#Script

function Test()
{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");

  // Obtain AutoCompleteTextView
  var p = Mobile["Device"].Process("com.example.myapp");
  var AutoText = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout3")["Layout"]("layout4")["AutoCompleteTextView"]("edit7");
  
  // Enter part of the text
  var Threshold = AutoText["mThreshold"]
  
  // Select the item of the ListView
  Log["Message"](Threshold);
}

Simulating Actions From Keyword Tests

This topic explains how to work with the auto complete text view control in scripts. You can use the described propery in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Selecting Text Within the Edit Text Control
Working With Android Edit Text Controls
GetListLength Method
wText Property (Edit Controls)

Highlight search results