Ask a Question

aqDateTime

SOLVED
gdave
Regular Contributor

aqDateTime

Hi all

 

I was trying to validate a date which is displayed on my screen. I am using below Code Expression to confirm that the date displayed is yesterday's date however I get an 'Exception' error message :"Unable to evaluate the operation's "Value" parameter. Error: Undeclared identifier: CurrentDate"

 

My Code is as below:

aqConvert.DateTimetoFormatStr(aqDateTime.AddDays(CurrentDate, -1), '%d/%m/%Y')

 

Can anyone please confirm the correct script as I doubt above is incorrect. Thanks

 

8 REPLIES 8
Marsha_R
Champion Level 3

I am guessing that you read the date off the screen and put it in CurrentDate?  Since we can't see the rest of your code, I'm also guessing from the error message that the variable isn't available to this part of the code.

 

Also make sure that CurrentDate is an actual date and not a string, since that is what aqDateTime is looking for.

m_essaid
Valued Contributor

yes, I bet your date variable is string, not a date... maybe convert it into DateTime before taking off one day...

gdave
Regular Contributor


@Marsha_Rwrote:

I am guessing that you read the date off the screen and put it in CurrentDate?  Since we can't see the rest of your code, I'm also guessing from the error message that the variable isn't available to this part of the code.

 

Also make sure that CurrentDate is an actual date and not a string, since that is what aqDateTime is looking for.


No, I just wish to read the date of the screen.

 

So the date displayed on the screen is yesterday's date. I used property checkpoint with property/method as 'text', condition:equals, value: code expression. Hope this make sense. Cheers

gdave
Regular Contributor


@m_essaidwrote:

yes, I bet your date variable is string, not a date... maybe convert it into DateTime before taking off one day...


Can you please give an example.....

m_essaid
Valued Contributor

sure :

 

test:= aqConvert.DateTimetoFormatStr(aqDateTime.AddDays(aqConvert.StrToDate('31/12/2018') , -1), '%d/%m/%Y')

 

you could instead of '31/12/2018' put any property of any object that returns a string, as ".Caption" or so on

cunderw
Community Hero

CurrDate is not something built in to the aqDateTime, not sure we're you're getting that. 

 

I think what you're looking for is aqDateTime.Today()

 

aqConvert.DateTimeToFormatStr(aqDateTime.AddDays(aqDateTime.Today(),-1),'%d/%m/%Y')

Thanks,
Carson

Click the Accept as Solution button if my answer has helped
tristaanogre
Esteemed Contributor


@cunderw wrote:

CurrDate is not something built in to the aqDateTime, not sure we're you're getting that. 

 

I think what you're looking for is aqDateTime.Today()

 

aqConvert.DateTimeToFormatStr(aqDateTime.AddDays(aqDateTime.Today(),-1),'%d/%m/%Y')

If "CurrentDate" is a variable you have declared and want to use it in the keyword test, you need to express it like so, again, assuming that "CurrentDate" has been converted to a DateTime object.  


aqConvert.DateTimetoFormatStr(aqDateTime.AddDays(KeywordTests.MyKeywordTest.Variables.CurrentDate, -1), '%d/%m/%Y')

 

BUT... if you always need to check that it's 1 day in the past... what @cunderw suggests is the better way.


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
gdave
Regular Contributor

Thanks for all your responses guys.

 

I always need to check that it's 1 day in the past and solution proposed by @cunderw worked.

 

Regards

G

cancel
Showing results for 
Search instead for 
Did you mean: