Planning Support for the WPF Calendar Control

Supported on versions 2021 R1 and earlier

In this section, you study the behavior of the control that you want to support and the way UFT One recognizes it and interacts with it. You then determine what you need to customize in UFT One's behavior in order to enable creating test steps that are more meaningful and easier to maintain.

Run the sample WPF Calendar application and study its behavior

  1. Double-click the <WPF and Silverlight Add-in Extensibility SDK installation folder>\samples\WPFExtCalendarSample\Application\WpfCalendar.exe file. The Calendar application opens.

    This application contains 3 controls:

    • A calendar display area with buttons: Microsoft.Windows.Controls.Calendar

    • A text label: System.Windows.Controls.TextBlock

    • An edit box displaying the selected date: System.Windows.Controls.TextBox

  2. Study the application's functionality.

    • You can click the right and left arrows to go the next or previous month.

    • You can select a date in the calendar by clicking on the relevant day of the month.

    • You can view the selected date in the text box.

Back to top

See how UFT One recognizes the controls

Use the Object Spy in UFT One to see how UFT One recognizes the controls in the Calendar application

  1. Open UFT One, and open a GUI test.

  2. Select Record > Record and Run Settings, and make sure that the selections in the Windows Applications tab enable UFT One to record and run tests on the calendar application.

  3. Run the Object Spy and spy on the WPF Calendar.

    UFT One recognizes the Calendar application as a WpfWindow. Within this window, it recognizes the Microsoft.Windows.Controls.Calendar control as a generic WpfObject and the System.Windows.Controls.TextBox as a WpfEdit object.

    Additionally, within the in the Microsoft.Windows.Controls.Calendar control, UFT One recognizes the days as independent WpfButtons in the WpfWindow.

    UFT One ignores other user interface elements contained in the Calendar control, such as the right and left arrows, and the month and year banner.

Back to top

Add test objects for the Calendar control

Learn the Calendar control using UFT One, adding it to an object repository

  1. Open the Object Repository.

  2. Click the Add Objects to Local button.

  3. Click on an area in the calendar.

  4. Add additional objects to the local object repository by clicking the Add Objects to Local button and then clicking on different areas of the calendar. For example, click on the days, the text box, or the month and year banner.

    UFT One learns the application as a WpfWindow. Within this window, it separately learns the calendar display area as a generic WpfObject and the Selected Date box as a WpfEdit object.

    The days are learned as independent WpfButtons, but other user interface elements, such as the right and left arrows, and the month and year banner, are not learned at all.

Back to top

Record a test on the Calendar control

  1. Click Record .

  2. Click on different areas in the calendar.

    When you click on the right or left arrows, or on the month and year banner, UFT One records a generic click on the WpfObject, specifying the coordinates of the location you clicked.

    When you click a day and select it, or when you click in the Selected Date box, nothing is recorded.

    When you click in other areas of the application, UFT One records a generic click on the WpfWindow.

    Back to top

Conclusion: Develop a MyWpfCalendar Test Object Class

  • For functional testing purposes, the Microsoft.Windows.Controls.Calendar control should be represented in UFT One by one MyWpfCalendar test object.

  • The buttons within the Calendar control should not be treated as separate controls.

  • The Selected Date box is a read-only box, on which no user activity is possible and no steps are recorded. Therefore, the System.Windows.Controls.TextBox control does not have to be supported as part of the MyWpfCalendar test object, and does not need any customization for functional testing.

  • The MyWpfCalendar test object class should be based on the existing UFT One test object class, WpfObject, and extend its capabilities.

  • The MyWpfCalendar test object class should support calendar-related operations.

    In this tutorial you develop support for the following test object methods: SetDate (default operation), Next, Previous, and a SelectedDate test object property.

  • User operations performed on the calendar's different user interface elements, should be interpreted and recorded as high-level operations on the calendar as a whole. For example: SetDate, Next, Previous, and so on.

  • The MyWpfCalendar test object class should support identification properties relevant for a calendar, such as is_today_highlighted.

Back to top

Continue to Setting Up the WPF Add-in Extensibility Project for the WPF Calendar Control.