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

Silverlight: How to select certain date in Calendar?

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
k
Top achievements
Rank 1
k asked on 10 Dec 2010, 12:32 PM

Hi!
I have a question.
Let's view http://www.artoftest.com/Samples/SampleApplication.html example.
I want to set some concrete date in calendar, e.g. 20th of December.
I created test in Recorder, and that's how click on date is recorded:

Pages.SampleApplication.SilverlightApp.Item24Calendardaybutton.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 10, 6,
ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Pixel, ((System.Windows.Forms.Keys)(0)));

But if I would play this test in another month, Item24Calendardaybutton will not be 20th of December anymore. How should I customize my code to select 20th number always?

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 13 Dec 2010, 02:48 PM
Hi,
    the problem is related to the fact that by default the click is recorded on a Silverlight object. When you run the test WebUI Test Studio locates the Date object by it's index in the Silverlight grid. It locates the object and clicks it. Unfortunately the Find Logic used to achieve this isn't related to the actual text contained in the object. This is why it won't locate the 20th correctly for a different month.

So we need to get the Date object using its text ("20") and click it. We need to avoid Silverlight for this to happen:
1) Start recording
2) Enable  the highlighting feature, and highlight the desired Date object (i.e. the 20 Date).
3) You will see 2 or 3 blue UI objects. Click on the first one (the round one) (see screenshot 1) - this opens the pop-up menu for the HTML object (a textblock) (remember - we don't want to use Silverlight because it doesn't care about the content of the textblock).

4) Now you need to record a mouse click. From the pop-up menu choose: Mouse Actions-->Left Click-->Center (see screenshot 2).

A new LeftClick steps will then appear in your test. That's it - this step should click on the 20th no matter what month it is because the Find Logic for the clickable object is just:
A textblock containing 20
Obviously such a text box would exist for all months.

Something to keep in mind - this won't work if you test it by the "Go to Next Month" button on the calender. This is because at the beginning of the execution WebUI Test Studio finds the object it's going to be clicking and stores it's coordinates. After that it will always try to click that object using the those coordinates even if meanwhile you used the "Go to Next Month" button and that changed its position.

I hope this helps! Please don't hesitate to contact us if you have any further questions!
  
Regards,
Stoich
the Telerik team
Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
k
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or