Thursday, December 07, 2006

Storing the current date in Selenium scripts

In my application I needed to put in the current date and it has to be in a specific format (yyyy-MMM-d) so taking the information I gathered from openacs.org/xowiki/en/Testing_with_Selenium I put in the following near the beginning of my Selenium script. The cool part here being the way I created an anonymous array that stores the text. Note the text between {} should all be in one line but is broken apart for clarity (and to make it fit in the window).

storeExpression
javascript{
var d = new Date();
d.getFullYear() + "-" +
[ "Jan", "Feb", "Mar",
  "Apr", "May", "Jun",
  "Jul", "Aug", "Sep",
  "Oct", "Nov", "Dec"]
[d.getMonth()] +
"-" + d.getDate()
}
today
And then to type it in a field.
type
__o3fwp.ACTION.dtls$dtls$acStaffingDate
${today}

0 comments: