Recording a step that uses a RadCalendar control

6 posts, 0 answers
  1. Lelia Irby
    Lelia Irby avatar
    3 posts
    Member since:
    May 2008

    Posted 21 Jun 2010 Link to this post

    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?
  2. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 22 Jun 2010 Link to this post

    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
  3. Lelia Irby
    Lelia Irby avatar
    3 posts
    Member since:
    May 2008

    Posted 23 Jun 2010 Link to this post

    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?
  4. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 25 Jun 2010 Link to this post

    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
  5. Lelia Irby
    Lelia Irby avatar
    3 posts
    Member since:
    May 2008

    Posted 25 Jun 2010 Link to this post

    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.
  6. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 25 Jun 2010 Link to this post

    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
Back to Top