Odin Technology - Automated Software Testing

Axe Test Automation Platform

General discussion relating to the Axe Test Automation Platform from Odin Technology

Posts by Odin employees marked:

Using the current date with a 'val' action

Axe v3.2, Selenium (Java)

Hi

I have a sub-test which verifies that a certain field in the application will contain the current date in the format dd-mm-yyyy.  I have attempted to use the Excel formula =TODAY() in the sub-test file with the cell formated as custom type 'dd-mm-yyyy', however this gets compiled into java files which substitute dd-mm-yyyy with "2011-09-13T00:00:00.000" - is there a way around this that you know of without creating a custom function?

Many thanks
Mark
Mark Winspear Send private email
Tuesday, September 13, 2011
 
 
Hi Mark,

You need to make sure all your dates are formated as text. e.g. in Excel you could achieve this by =TEXT(TODAY(), "dd-mmm-yy")

However, I would advise against doing it this way, since the date will only be calculated when the spreadsheet is saved. So best-practice in these cases is to use s custom 'load' action to generate the date dynamically at run time.

Sam
Sam Warwick Send private email
Wednesday, September 14, 2011
 
 
Thanks Sam

Were you anticipating that a custom load would need to call a custom java function to return the current date?
Mark Winspear Send private email
Wednesday, September 14, 2011
 
 
Hi Mark,

Yes. In its simplest form:

action: load.date
command: date = new SimpleDateFormat("dd/MM/yyyy hh:mm a").format(Calendar.getInstance().getTime())

Obviously you could make this more advanced by passing the formating as a parameter to the action etc.
The key thing here is to make it a load action. That way all ensuing 'set' and 'val' actions will automatically use the value, just as if the data had been loaded from a file.

Sam
Sam Warwick Send private email
Thursday, September 15, 2011
 
 
Thanks Sam

I added 'String' before date and added the necessary import statements to the SeleniumJava.ActionMap, however the action when AXE runs seems to return 'null' - I'll have a look into it when I get time.

Thanks again
Mark
Mark Winspear Send private email
Thursday, September 15, 2011
 
 
Hi Mark,

Sorry, there are a few mistakes in the above. If you are using the Jacob COM bridge, then the full command is:

Dispatch.put(axe, "Data", new SimpleDateFormat("dd/MM/yyyy hh:mm a").format(Calendar.getInstance().getTime()))

Sam
Sam Warwick Send private email
Monday, September 19, 2011
 
 
For completeness, the additional imports required are:

import java.text.SimpleDateFormat;
import java.util.Calendar;
Sam Warwick Send private email
Monday, September 19, 2011
 
 
Thanks Sam, that's really useful
Mark Winspear Send private email
Monday, September 19, 2011
 
 
Hi Sam

I was looking for a quick bit of advice.  This application deals a fair amount with date manipulation (ie some tests will need to add values to the current date.  I had created a new function called load.today(field,amount) with the command

Dispatch.put(axe, "Data", new SimpleDateFormat("dd-MM-yyyy").format(Calendar.getInstance().add(%PARAM1%, %PARAM2%)))

and used this within a test as load.today(DAY_OF_MONTH,1);set

however, on build, axe reports
java233: cannot find symbol
symbol: variable DAY_OF_MONTH

Any ideas what's gone wrong here?

Many thanks

Mark
Mark Winspear Send private email
Tuesday, October 4, 2011
 
 
An amended attempt adding "Calendar." before PARAM1:

Dispatch.put(axe, "Data", new SimpleDateFormat("dd-MM-yyyy").format(Calendar.getInstance().add(Calendar.%PARAM1%, %PARAM2%)))

This returns a different error java:223 'void' type not allowed here
Mark Winspear Send private email
Tuesday, October 4, 2011
 
 
Assuming this question is now covered in http://fogbugz.odin.co.uk/default.asp?axe.1.56671.0
Sam Warwick Send private email
Monday, October 10, 2011
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics