Determining DatePicker Date

Applies to TestComplete 14.93, last modified on September 16, 2021
Determining the DatePicker Date

To determine the date displayed by a DatePicker control, use the wDate property of the iOS DatePicker object that TestComplete associates with that control. The date format of the wDate property depends on the regional setting of the machine performing the test, not the settings of the mobile device. The following example checks the date on the DatePicker and posts it to the log:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the DatePicker object
  var p = Mobile.Device().Process("SampleApp");
  var datepicker = p.Window().DatePicker();

  // Post DatePicker date to the log
  Log.Message(datepicker.wDate);
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the DatePicker object 
  p = Mobile.Device().Process("SampleApp")
  datepicker = p.Window().DatePicker()

  # Post DatePicker date to the log
  Log.Message(datepicker.wDate)

VBScript

Sub Test()
  Dim p, datepicker
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the DatePicker object
  Set p = Mobile.Device.Process("SampleApp")
  Set datepicker = p.Window(2).DatePicker

  ' Post DatePicker date to the log
  Log.Message(datepicker.wDate)
End Sub

DelphiScript

procedure Test();
var
  p, datepicker;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the DatePicker object
  p := Mobile.Device.Process('SampleApp');
  datepicker := p.Window(2).DatePicker;

  // Post DatePicker date to the log
  Log.Message(datepicker.wDate);
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the DatePicker object
  var p = Mobile["Device"].Process("SampleApp");
  var datepicker = p["Window"](2)["DatePicker"]();

  // Post DatePicker date to the log
  Log["Message"](datepicker["wDate"]);
}

Getting Date From Keyword Tests

To get the current date picker value from keyword tests, call the methods described above by using the On-Screen Action or Call Object Method operation. See Calling Object Methods.

See Also

Working With iOS Date Picker Controls
Changing DatePicker Date
wDate Property (Mobile Controls)

Highlight search results