testing calendar

4 posts, 1 answers
  1. Nicolas
    Nicolas avatar
    60 posts
    Member since:
    Nov 2010

    Posted 31 Aug 2011 Link to this post

    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
  2. Answer
    Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 03 Sep 2011 Link to this post

    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!
  3. Nicolas
    Nicolas avatar
    60 posts
    Member since:
    Nov 2010

    Posted 06 Sep 2011 Link to this post

    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
  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 09 Sep 2011 Link to this post

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