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

Selecting specific slots in radscheduleview

2 Answers 134 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shashi
Top achievements
Rank 1
Shashi asked on 29 May 2012, 09:46 PM
Hello,

Our dev team recently updated the Scheduling page in our application to use a RadScheduleView instead of a Radscheduler.  This has broken most of our tests that were written to work with the radscheduler and we are working through the issues to fix them.  This post is to ask you about one of the issues.

One of our tests was creating an appointment by selecting a specific row in the Scheduler view and then invoking the Create Appointment command from the right-mouse menu associated with that row (the time slot values are used to populate the Time fields in the dialog that shows up).  

The selected row was computed based on the desired time (which was one of about 6 possible values that the test would pick from in each run).  Here is the code:

[CodedStep(@"RightClick on Item250Border", RequiresSilverlight = true)]
public void CreateAppointment_CodedStep()
{
    //declare variables and set to null
    int beforeAppCount = Convert.ToInt16(GetExtractedValue("BeforeAppointmentCount")); //before count
    int appTimeIndex = beforeAppCount % 5;
    // Appointment start times will cycle between 10:00 AM, 1:00 pm, 2:00pm, 3:15 PM and 4:00 PM
    switch (appTimeIndex)
    {
        case 0:
            // RightClick on Item154Border - 10:00 am
            Log.WriteLine("Creating appointment at 10:00 AM");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item154Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 45, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
        case 1:
            // RightClick on Item202Border - 1:00pm
            Log.WriteLine("Creating appointment at 1 PM");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item202Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 55, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
        case 2:
            // RightClick on Item218Border - 2:00pm
            Log.WriteLine("Creating appointment at 2 PM");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item218Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 30, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
        case 3:
            // RightClick on Item238Border - 3:15pm
            Log.WriteLine("Creating appointment at 3:15 PM");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item238Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 40, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
        case 4:
            // RightClick on Item250Border -  4:00pm
            Log.WriteLine("Creating appointment at 4 PM");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item250Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 40, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
        default:  // this code should never be executed as long as the number of appointment time options is 3
            // RightClick on Item154Border - 10:00 am
            Log.WriteLine("Creating appointment at 10 AM (default)");
            Pages.QAAUTOSYNC1228183918.SilverlightApp.Item154Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 45, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
            break;
    }               
}

The above code worked with the Radscheduler because each row was associated with a different Border object (which was enclosed in a TimeSlotItem object).  However, I am finding that is not the case with the Radscheduler view.  When I record the right mouse click (prior to taking it to code), I seem to be getting the same id no matter which row I pick. 

When I look at the DOM, I don't see Border elements for any of the rows - instead I am seeing TimeRulerLine elements inside a TimeRulerLinesPanel element.  Each of the TimeRuler elements does have a Border element - but the recorder is apparently not finding them or not seeing them as different objects.

Question:  Given the above, is it possible to replicate the test functionality (as it worked with Radscheduler) to work with Radscheduleview?  If so, what do I need to do?

Attached are snapshots of the scheduler page with Radscheduleview (radschedulerview.jpg) and radscheduler (radscheduler.jpg) with the respective DOM shown alongside.

I appreciate your help in this regard.  A prompt response would be very much appreciated as the test in question is a smoke test and needs to be fixed as soon as possible.  Please let me know if you have further questions.

Thanks,
Shashi  

2 Answers, 1 is accepted

Sort by
0
Shashi
Top achievements
Rank 1
answered on 04 Jun 2012, 03:58 PM
Does anyone have any suggestions for this?

Thanks,
Shashi
0
Cody
Telerik team
answered on 04 Jun 2012, 10:26 PM
Hi,

I apologize for the delay getting back to you.

This is difficult because we have not yet created a control wrapper for the RadScheduleView control. I suggest using code like this to find the time slot desired and click or act on it.

bool found = false;
 
MySampleTests.Pages.TelerikScheduleViewForPage.SilverlightAppElement app = Pages.TelerikScheduleViewFor.SilverlightApp;
IList<FrameworkElement> timeslots = app.Find.AllByType("TimeRulerItem");
System.Drawing.Rectangle appointments = app.Find.ByType("AppointmentsPanel").GetScreenRectangle();
 
Assert.IsTrue(timeslots.Count > 0);
foreach (FrameworkElement slot in timeslots)
{
    if (slot.TextBlockContent.Contains("8:00 AM"))
    {
        slot.EnsureClickable();
        System.Drawing.Rectangle slotRectangle = slot.GetScreenRectangle();
        ActiveBrowser.Desktop.Mouse.HoverOver(appointments.Width / 2 + appointments.X, slotRectangle.Height / 4 + slotRectangle.Y);
        found = true;
        break;
    }
}
Assert.IsTrue(found);

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Shashi
Top achievements
Rank 1
Answers by
Shashi
Top achievements
Rank 1
Cody
Telerik team
Share this question
or