Checking a Calendar's Date Range

Applies to TestComplete 15.69, last modified on November 13, 2024
Getting wMaxDate and wMinDate Properties

To determine the minimum and maximum dates of a calendar control, use the wMaxDate and wMinDate properties of the Android CalendarView object that TestComplete associates with that control. These properties return the values of the first and the last possible day of the calendar control. The following example determines the minimum and maximum dates of the calendar and posts them to the log:

JavaScript, JScript

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

  // Obtain the CalendarView object
  var p = Mobile.Device().Process("com.example.myapp");
  var CalendarView = p.RootLayout("").Layout("layoutTop").Layout("layout2").CalendarView("calendarView1");
  
  // Get the min and max dates
  var CalendarMinDate = CalendarView.wMinDate;
  var CalendarMaxDate = CalendarView.wMaxDate;
  
  // Post the dates to the log
  Log.Message(CalendarMinDate);
  Log.Message(CalendarMaxDate);
}

Python

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

  # Obtain the CalendarView object
  p = Mobile.Device().Process("com.example.myapp")
  CalendarView = p.RootLayout("").Layout("layoutTop").Layout("layout2").CalendarView("calendarView1")
  
  # Get the min and max dates
  CalendarMinDate = CalendarView.wMinDate
  CalendarMaxDate = CalendarView.wMaxDate
  
  # Post the dates to the log
  Log.Message(CalendarMinDate)
  Log.Message(CalendarMaxDate)

VBScript

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

  ' Obtain the CalendarView object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set CalendarView = p.RootLayout("").Layout("layoutTop").Layout("layout2").CalendarView("calendarView1")
  
  ' Get the min and max dates
  CalendarMinDate = CalendarView.wMinDate
  CalendarMaxDate = CalendarView.wMaxDate
  
  ' Post the dates to the log
  Log.Message(CalendarMinDate)
  Log.Message(CalendarMaxDate)
End Sub

DelphiScript

procedure Test();
var
  p, CalendarView, CalendarMinDate, CalendarMaxDate : OleVariant;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain the CalendarView object
  p := Mobile.Device.Process('com.example.myapp');
  CalendarView := p.RootLayout('').Layout('layoutTop').Layout('layout2').CalendarView('calendarView1');
  
  // Get the min and max dates
  CalendarMinDate := CalendarView.wMinDate;
  CalendarMaxDate := CalendarView.wMaxDate;
  
  // Post the dates to the log
  Log.Message(CalendarMinDate);
  Log.Message(CalendarMaxDate);
end;

C++Script, C#Script

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

  // Obtain the CalendarView object
  var p = Mobile["Device"]["Process"]("com.example.myapp");
  var CalendarView = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout2")["CalendarView"]("calendarView1");
  
  // Get the min and max dates
  var CalendarMinDate = CalendarView["wMinDate"];
  var CalendarMaxDate = CalendarView["wMaxDate"];
  
  // Post the dates to the log
  Log["Message"](CalendarMinDate);
  Log["Message"](CalendarMaxDate);
}

The date format of the wMinDate and wMaxDate properties depends on the regional setting of the computer running the test, not the settings of the mobile device.
Simulating Actions From Keyword Tests

This topic explains how to determine the first and last date of the calendar control in scripts. You can use the described properties in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Calendar Controls
wMaxDate Property (Mobile Controls)
wMinDate Property (Mobile Controls)
Determining and Changing Calendar Date

Highlight search results