Typing in todays date

14 posts, 0 answers
  1. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 28 Jun 2011 Link to this post

    I want to have Test Studio enter todays date.
    If it is  6/1/2011 or 6/10/2011 what ever the current date is.
    Can it check my computer or the web for the date?
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 28 Jun 2011 Link to this post

    Hello Sebastian,

    This can be accomplished with code by checking the date on the local machine. But an easier, codeless approach is to use Test Studio's Data Bind an Extraction Step feature:
    1. Navigate to a site that displays today's date.
    2. Perform an Extract verification on that element.
    3. Navigate to the page where you want to enter the date.
    4. Data Bind the "Set Text" step with the DataBindVariableName from the Extract step.

    Best wishes,
    Anthony
    the Telerik team
    Register today 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?
  3. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 28 Jun 2011 Link to this post

    I'd rather get it from my computer due to ever changing web sites.
    Can you send me the coded step?
  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 28 Jun 2011 Link to this post

    Hi Sebastian,

    A simple google search returned many possibilities, such as here, but this is what worked for me:

    Pages.Bing.SbFormQText.Text = DateTime.Now.ToString("M/d/yyyy");

    This example inputted today's date, 6/28/2011, into the search field at www.bing.com.

    All the best,
    Anthony
    the Telerik team
    Register today 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?
  5. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 28 Jun 2011 Link to this post

    Sorry I wasn't clear.
    I want to get the date from my computers BIOS clock.
  6. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 28 Jun 2011 Link to this post

    Hello Sebastian,

    You were perfectly clear. The example I gave does in fact use the computer's BIOS clock. I simply used it in the context of getting the BIOS date, converting it to a string, and using that string to search Bing.

    Of course, you would alter the code to the left of the equals sign to match the applicable page, element, and attribute in your test.

    All the best,
    Anthony
    the Telerik team
    Register today 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?
  7. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 12 Jul 2011 Link to this post

    I'm stuck with this.
    When I type in Pages. a list is hot keyed.  When I look over the list it is showing places on the site I'm working with.
    Can I just tell it where exactly I want to put the date?

    RadInput ??

    The Tag Name is -
    ct00_Contentplaceholder1_ucDeclareEvent_rdpEventDate_dateInpt_wrapper

  8. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 12 Jul 2011 Link to this post

    Man I'm very close!

    It came to me that I could do a Text entry in to the box and get a RadInput step.
    Then I coverted it to code and added in the   DateTime.Today.ToString("MM/DD/YYYY")
    Giving me-


    Pages.HttpsProdpreview5.FrameRwLifeEvent.Contentplaceholder1UcDeclareEventRdpEventDateDateInputWrapperSpan.TypeText(DateTime.Today.ToString(

     

    "MM/DD/YYYY"));

    The date gets entered.
    The only problem is today is 7/12/2011.
    It is entering 7/7/2011.
    Where am I going wrong?

     

  9. Sebastian
    Sebastian avatar
    80 posts
    Member since:
    Feb 2011

    Posted 12 Jul 2011 Link to this post

    I got it!

    I changed the date part to  ("MM/dd/yyyy")

    I had ("MM/DD/YYYY")

    Caps made the difference
  10. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 12 Jul 2011 Link to this post

    Hi Sebastian,

    I just tested this on a Telerik demo site. Both variations entered today's date successfully:

    //your version
    Pages.ASPNETInputDemo.RadDatePicker1DateInputWrapperSpan.TypeText(DateTime.Today.ToString("M/d/yyyy"));
     
    //my version
    Pages.ASPNETInputDemo.RadDatePicker1DateInputWrapperSpan.TypeText(DateTime.Now.ToString("M/d/yyyy"));


    Since this code pulls directly from the date of the operating system, is the date set incorrectly in Windows?

    All the best,
    Anthony
    the Telerik team
    Register today 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?
  11. Chris
    Chris avatar
    17 posts
    Member since:
    Sep 2011

    Posted 04 Oct 2011 Link to this post

    This post has been very helpful, thank you.
    'Set 'CaseEditor1StartDateText' text to 'TODAY'
    Pages.CaseDetails3.CaseEditor1StartDateText.Text = DateTime.Now.ToString("M/d/yyyy")

    Can I add and subtract days from this function?
    -Chris
  12. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 05 Oct 2011 Link to this post

    Hi Chris,

    Yes; see here for more information on that topic.

    Here's the code that worked for me:

    System.DateTime today = System.DateTime.Now;
     
    //Use a negative number subtract days or a positive number to add days
    System.DateTime answer = today.AddDays(-10);
     
    Pages.Bing.SbFormQText.Text = answer.ToString("M/d/yyyy");

     Kind regards,
    Anthony
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Sundar
    Sundar avatar
    4 posts
    Member since:
    Feb 2017

    Posted 23 Nov 2017 in reply to Anthony Link to this post

    This post if from 2011. Has there been any improvement in the product to get today's date, instead of coding?

    If so how can we achieve it? Can anyone give exact steps to be performed to obtain this.

    Also I want to have add 15 Days from today's date as another requirement.

  14. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    971 posts

    Posted 27 Nov 2017 Link to this post

    Hi Sundar,

    Thank you for your interest in Test Studio. 

    Please note that this is a standard coded approach based on .NET framework which could be used across any .Net based applications including a coded step in Test Studio test. Also it could be modified as per the individual requirements. 

    Please let me know if there is any further information we could share. Thanks in advance for your understanding! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top