SmartBear Connect 2018
Join us at SmartBear Connect 2018 on October 29th & 30th in Boston, MA.
Come meet the team behind your tools – get your ticket today!
Reply
Contributor

system date retrieve

i have written below code to retrieve the system date or records created date :6/13/2018 10:42:18 AM

 

var NowValue = aqDateTime.Now();
if("Created Date"==NowValue)
{ RowIndex7 = Grid.FindRow("Created Date", NowValue);
if (RowIndex7 != -1)
Grid.ClickCell(RowIndex7, "Created Date");

log,message ("row exists)

else log.error("row not found)

 

somehow the balove script doesnot picks the value and gives row not found. any suggestions

Posts: 5,634
Topics: 43
Kudos: 2,491
Solutions: 503
Registered: ‎11-30-2009

Re: system date retrieve

aqDateTime.Now() does not return a string... it returns an object type of DateTime...  So, to compare that to a string from a grid is a mismatched comparison.  you need to convert aqDateTime.Now() to the format that matches what you're looking for in your grid.  Use aqConvert.DateTimeToFormatStr to do so.


Robert Martin
[Community Expert Group]
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.

Extensions available
Community Leaders Program
Contributor

Re: system date retrieve

Thanks Martin! but how can I specify AM or PM. Is there any way to format n specify AM and PM.

 

 var FormatStr = aqConvert.DateTimeToFormatStr(NowValue, "%#m/%#d/%Y %I:%M:%S")

 

Highlighted
Posts: 5,634
Topics: 43
Kudos: 2,491
Solutions: 503
Registered: ‎11-30-2009

Re: system date retrieve

Yes.  All format specifiers can be found at https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/date-and-time-f...

 

Change your code to


var FormatStr = aqConvert.DateTimeToFormatStr(NowValue, "%#m/%#d/%Y %I:%M:%S %p")

Robert Martin
[Community Expert Group]
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.

Extensions available
Community Leaders Program