Determining the Number Picker Text

Applies to TestComplete 15.45, last modified on December 01, 2022
Getting the wText Property

To determine the text value of a number picker, use the wText property. The example below obtains the text displayed by the number picker control and posts it to the log:

JavaScript, JScript

function Test()
{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");
  
  // Obtain the NumberPicker object
  var p = Mobile.Device().Process("com.example.myapp");
  var NumberPicker = p.RootLayout("").Layout("layoutTop").Layout("layoutNums").NumberPicker("numberPicker2");
 
  // Obtain the text displayed by the control
  var text = NumberPicker.wText;
  
  // Post the text to the log
  Log.Message(text);
}

Python

def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  # Obtain the NumberPicker object
  p = Mobile.Device().Process("com.example.myapp")
  NumberPicker = p.RootLayout("").Layout("layoutTop").Layout("layoutNums").NumberPicker("numberPicker2")
 
  # Obtain the text displayed by the control
  text = NumberPicker.wText
  
  # Post the text to the log
  Log.Message(text)

VBScript

Sub Test()
  ' Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  ' Obtain the NumberPicker object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set NumberPicker = p.RootLayout("").Layout("layoutTop").Layout("layoutNums").NumberPicker("numberPicker2")
 
  ' Obtain the text displayed by the control
  text = NumberPicker.wText
  
  ' Post the text to the log
  Log.Message(text)
End Sub

DelphiScript

function Test();
var
  p, NumberPicker, text : OleVariant;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');
  
  // Obtain the NumberPicker object
  p := Mobile.Device.Process('com.example.myapp');
  NumberPicker := p.RootLayout('').Layout('layoutTop').Layout('layoutNums').NumberPicker('numberPicker2');
 
  // Obtain the text displayed by the control
  text := NumberPicker.wText;
  
  // Post the text to the log
  Log.Message(text)
end;

C++Script, C#Script

function Test()
{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");
  
  // Obtain the NumberPicker object
  var p = Mobile["Device"].Process("com.example.myapp");
  var NumberPicker = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layoutNums")["NumberPicker"]("numberPicker2");
 
  // Obtain the text displayed by the control
  var text = NumberPicker["wText"];
  
  // Post the text to the log
  Log["Message"](text);
}

Using From Keyword Tests

This topic explains how to determine the current position of the number picker control in scripts. You can use the described property in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Number Picker Controls
Determining Minimum and Maximum Number Picker Values

Highlight search results