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

Typing in todays date

13 Answers 333 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 28 Jun 2011, 08:43 PM
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?

13 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 28 Jun 2011, 09:16 PM
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?
0
Sebastian
Top achievements
Rank 1
answered on 28 Jun 2011, 10:03 PM
I'd rather get it from my computer due to ever changing web sites.
Can you send me the coded step?
0
Anthony
Telerik team
answered on 28 Jun 2011, 10:19 PM
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?
0
Sebastian
Top achievements
Rank 1
answered on 28 Jun 2011, 10:37 PM
Sorry I wasn't clear.
I want to get the date from my computers BIOS clock.
0
Anthony
Telerik team
answered on 28 Jun 2011, 10:49 PM
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?
0
Sebastian
Top achievements
Rank 1
answered on 12 Jul 2011, 01:39 PM
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

0
Sebastian
Top achievements
Rank 1
answered on 12 Jul 2011, 03:29 PM
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?

 

0
Sebastian
Top achievements
Rank 1
answered on 12 Jul 2011, 03:44 PM
I got it!

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

I had ("MM/DD/YYYY")

Caps made the difference
0
Anthony
Telerik team
answered on 12 Jul 2011, 03:49 PM
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?
0
Chris
Top achievements
Rank 2
answered on 05 Oct 2011, 01:01 AM
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
0
Anthony
Telerik team
answered on 05 Oct 2011, 05:07 PM
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
0
Sundar
Top achievements
Rank 1
answered on 23 Nov 2017, 10:44 PM

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.

0
Elena
Telerik team
answered on 27 Nov 2017, 10:01 AM
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!
Tags
General Discussions
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Sebastian
Top achievements
Rank 1
Chris
Top achievements
Rank 2
Sundar
Top achievements
Rank 1
Elena
Telerik team
Share this question
or