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

testing calendar

3 Answers 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 31 Aug 2011, 04:24 PM
hello ,
how to click on element in  javascript calendar, by coded steps  ?attached a screen shot of my calendar
this demotrate how I select the date by clicking in its elements ,
thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Stoich
Telerik team
answered on 03 Sep 2011, 04:56 PM
Hi Nicolas,
    if you grant me access to your actual calendar control, I'd be happy to a sample coded step for you.

I put together a little sample block of code. It demonstrates how to click on the javascript calendar found in this page (scroll to the bottom):
http://calendarview.org/

I wrote the code after examining the DOM structure of the calendar (screenshot 1):
HtmlDiv cld =      Find.ByAttributes<HtmlDiv>("class=calendar"); //We see that the class is a good way to locate the calendar;
cld.ScrollToVisible(); //Let's scroll down to the table so that we ca view it
HtmlTable tbl = cld.Find.AllByTagName<HtmlTable>("table")[0];//the calendar is actually a table element
 
HtmlTableCell tt = tbl.Find.ByContent<HtmlTableCell>("15"); //each date in the calendar is actually a table cell. Look for the cell inside of the table that has the number 15;
tt.MouseClick(); //Click on the desired date
I hope this example gives you an idea how to deal with your own automation challenge.

Best wishes,
Stoich
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
Nicolas
Top achievements
Rank 1
answered on 06 Sep 2011, 10:28 AM
Hello

Thank you very much for your answer, it really helped me
I used HtmlTableCell tbl.Find.ByContent <HtmlTableCell> tt = ("15") to identify and click the corresponding item
  my test runs against much of the QA Edition version but not on the server running, where I run it in the on remote executionserver, the problem is that it can not click on the element because it  is faster than the version
Qa Edition, so it has no time to identify and click on that element, and on this step, I get this error message:
'9 / 6 / 2011 10:21:19 AM '-' Fail ': 14. [WebTestOdigo_CodedStep]: Click 'x2TableCell'
-------------------------------------------------- ----------
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step: [WebTestOdigo_CodedStep]: Click 'x2TableCell.''
InnerException:
System.NullReferenceException: Object reference not set to instance of year year object.
TestProjectOdigo.WebTestOdigo.WebTestOdigo_CodedStep at () in c: \ Tests \ NonRegressionsTests \ TestProjectOdigo \ WebTestOdigo.tstest.cs: line 104

Best regards
0
Anthony
Telerik team
answered on 09 Sep 2011, 03:08 PM
Hi Nicolas,

As part of best practices we recommend including verifications frequently in your code to ensure certain conditions are met before proceeding with your test. Please see this page for examples on how to do that in code.

As a last resort you can always use an execution delay, where the number in parenthesis is the time to delay in milliseconds:

System.Threading.Thread.Sleep(1500);


Greetings,
Anthony
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
Tags
General Discussions
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Nicolas
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or