yes, this sounds like something that can only be done in code. I've put together a working example for the calendar at the bottom of your page
. Keep in mind that there's more than one possible solution to this automation task and it's quite possible that there's a simpler (i.e. better) way to do it.
Also it seems that currently your application is never well equipped for UI Automation. Check out this article:
I took a close look at the DOM Tree of the app in order to determine the best way to distinguish between available and unavailable dates. It seems that the easiest way is based on the class (screenshot 1).
Here's the code I used along with comments explaining how it works:
//We scroll to the date picker so that we can see the click occuring
HtmlUnorderedList calendar = Find.ByExpression<HtmlUnorderedList>(
//The Date Picker is actually an HTML List. We use the class name days to locate it. Both calendars have the same class name so this returns the first one. You can Find.AllByExpression to get the second one. The logic is applicable for both of them.
LinkedList<HtmlListItem> availableDates =
//We initalize a collection to store all "available" (i.e. green of purple) dates from the calendar
//Go through all the dates in the calendar. The dates are actually HTML List items
) || i.CssClass.Equals(
//Green dates belong to class "promotion" while the purple one belongs to class "active"
//If the date checks out as "available" we added to the list
Random r =
randomNum = r.Next(availableDates.Count);
//We generate a random number which will corespond to an item in our list
LinkedListNode<HtmlListItem> l = availableDates.First;
//l will be the date we're going to select in the Calendar
(randomNum != 0)
//This loop moves up the linked list until we reach the node that coresponds to our randomly generated number
l = l.Next;
//Click on the node after we reach it in the list
I've attached a fully functional test to this post. Let me know if you need any further assistance on this task.
All the best,
the Telerik team
for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!
Have you looked at the new Online User Guide
for Telerik Test Studio?