This is a migrated thread and some comments may be shown as answers.

Recording a step that uses a RadCalendar control

5 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lelia Irby
Top achievements
Rank 1
Lelia Irby asked on 21 Jun 2010, 04:31 PM
I'm trying to record a test that enters a date range by selecting dates from RadCalendar controls.  When the test is run in a different month from when it was recorded, it fails (of course).  I assume there must be a way to create steps to explicitly specify the dates to be used in the test instead of manipulating the calendar control.  Can someone suggest how to do that?

5 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 22 Jun 2010, 01:21 PM
Hello Lelia,

The simplest approach to solve this problem is, if you have control over the tested page, to set the FocusedDate property of the Calendar to a value representing the month in which the test operates.

Alternatively you can simply navigate the Calendar to a specific month in the beginning of the test. Thus you ensure the steps that follow will not be affected by the date of the machine on which they are executed.

Finally, if you want to work with current dates, you can use code similar to the following:
RadCalendar calendar = this.Find.ById<RadCalendar>("RadCalendar1");
calendar.SelectDate(DateTime.Today.AddDays(5));
Assert.IsTrue(calendar.SelectedDates.Matches(new SelectedDateCollection(new DateTime[] { DateTime.Today.AddDays(5) })), "RadCalendar: Selected dates verification failed!");

I hope this helps.

Sincerely yours,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lelia Irby
Top achievements
Rank 1
answered on 23 Jun 2010, 02:47 PM
Thanks, Pavel.  The thing is, I'm not trying to test the Rad controls.  I'll trust you guys to do that. :-)  I'm just trying to get through the Rad  controls to get to the site functionality that I need to test.  In this case, I'm testing a report function that requires a date range to be specified using RadCalendar controls.  It seems to me that I should just be able to put specific dates into the input fields that are normally set using RadCalendars.  I want the report to cover the same period each time the test is executed (for known results).  Your solution #3 doesn't really suit my requirements, and the first 2 seem unnecessarily complicated.  No simpler way?
0
Pavel
Telerik team
answered on 25 Jun 2010, 08:26 AM
Hello Lelia,

If I understand correctly from your last message, you want to populate RadDatePicker controls, which can be done by simply typing in the input fields. Otherwise I don't think adding a few additional steps/clicks to navigate the control, or setting one property in its markup is much of a problem, as this is how the control works/behaves when it is used by real users.

Kind regards,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Lelia Irby
Top achievements
Rank 1
answered on 25 Jun 2010, 03:04 PM
I have tried that, actually.  While recording, if I delete the default date values and type the values I want into the RadInput fields, the report is generated properly, using the dates I typed in.  However, when I execute the test, what I see being "typed" into the date field is the default date concatenated with the date I typed into the field (e.g., "6/21/20105/1/2010"), causing the test to fail because the input values are not legitimate dates.
0
Pavel
Telerik team
answered on 25 Jun 2010, 03:54 PM
Hello Lelia,

In that case what you need to do is clear the value before entering a new one.

There are a few options to do this:
  • If you can modify the tested page you can set SelectionOnFocus="SelectAll" for the Input part of the RadDatePicker control. This will ensure that every time the input receives focus, the text in it will be selected which will delete the old value if you type a new one.
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <DateInput SelectionOnFocus="SelectAll"></DateInput>
    </telerik:RadDatePicker>
  • You can clear the value with code similar to the following:
    RadPicker picker = this.Find.ById<RadPicker>("RadDatePicker1_wrapper");
    picker.DateInput.Clear();
  • Finally you can simply record the deletion of the value and than type a new one. You should make sure however that the necessary steps to delete the value are properly recorded.


Greetings,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Lelia Irby
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Lelia Irby
Top achievements
Rank 1
Share this question
or