Getting wPosition Property
To determine the current value of a number picker in an Android application, use the wValue property. The following example shows how to get the current value of the number picker control:
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("numberPicker1");
// Get the NumberPicker value
var Value = NumberPicker.wValue;
// Post the value to the log
Log.Message(Value);
}
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("numberPicker1")
# Get the NumberPicker value
Value = NumberPicker.wValue
# Post the value to the log
Log.Message(Value)
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("numberPicker1")
' Get the NumberPicker value
Value = NumberPicker.wValue
' Post the value to the log
Log.Message(Value)
End Sub
DelphiScript
function Test();
var
p, NumberPicker, Position : 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('numberPicker1');
// Get the NumberPicker value
Value := NumberPicker.wValue;
// Post the value to the log
Log.Message(Value);
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"]("numberPicker1");
// Get the NumberPicker value
var Value = NumberPicker["wValue"];
// Post the value to the log
Log["Message"](Value);
}
Using From Keyword Tests
This topic explains how to determine the current value 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