Changing DatePicker Date

Applies to TestComplete 15.47, last modified on January 20, 2023
Changing the DatePicker Date

To change the date of a DatePicker control, assign the required value to the wDate property of the iOS DatePicker object that TestComplete associates with that control. The value you want to assign must follow the regional standards of the machine performing the test, otherwise, the error will occur. The following example sets the date of the DatePicker control to January 1, 2014:

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(2).DatePicker();

  // Set DatePicker date
  datepicker.wDate = "01/01/2014 14:24 AM";
}

Python

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

  # Set DatePicker date
  datepicker.wDate = "01/01/2014 14:24 AM"

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

  ' Set DatePicker date
  datepicker.wDate = "01/01/2014 10:24 PM"
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;

  // Set DatePicker date
  datepicker.wDate := '01/01/2014 10:24 PM';
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"]();

  // Set DatePicker date
  datepicker["wDate"] = "01/01/2014 10:24 PM";
}

Setting Date From Keyword Tests

To set 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
Checking a DatePicker's Date Range
wDate Property (Mobile Controls)

Highlight search results