Ask a Question

Testing for Current Date in a Text Box


Testing for Current Date in a Text Box

Hi! I'm trying to find a way to test for the current date in a text box (formatted as MM/DD/YYYY). Is there a way to do this using the front end? If not, what would the code look like using JScript?




Kevin Kleint

Community Hero

Re: Testing for Current Date in a Text Box

So, you're checking to see if the text box contains the current date, is that correct?


Well, I'm assuming the text box has some sort of property like "text" or "wText" or something like that.  You know the date is formatted as MM/DD/YYYY so, this is what I propose.

var currentDate = aqConvert.DateTimetoFormatStr(aqDateTime.Today(), '%m/%d/%Y');
if (myTextBox.wText === currentDate) {
    Log.Message('They match');
else {
    Log.Error('The dates do not match');

Alternatively, if you're using KeywordTests, you COULD do a properyCheckpoint on that propery and set the value that you are checking to a code expression of 


aqConvert.DateTimetoFormatStr(aqDateTime.Today(), '%m/%d/%Y')

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Re: Testing for Current Date in a Text Box



I thought about it a little bit and figured it out. This was the code I used.  Thanks for your input though!


function showPresentDate()


dt = new Date(); //Gets today's date right now (to the millisecond).

month = dt.getMonth()+1;
day = dt.getDate();
year = dt.getFullYear();
presentdate = month + '/' + day + '/' + year;

aqObject.CheckProperty(Aliases.ceraexe0.dlgServices.EditReceived, "wText", cmpEqual, presentdate);




Kevin Kleint

Showing results for 
Search instead for 
Did you mean: