- kelt65
- Posts : 2
Join date : 2012-10-30
[SOLVED] Need to add arbitrary number of days to date in date picking fields ...
Tue Oct 30, 2012 2:00 am
Keep in mind I know next to nothing about javascript, but this is easy enough with something like:
But this is worthless, since it will come up with "month 13" in December, instead of January.
Even though the following js code produces a valid date 30 days in the future, I can't figure out how to store this as an expression in Selenium ...
How can I reliably add 30 days or so to a date when picking a date field?
SOLVED -
I managed to do it this way:
Then you can call it with
- Code:
storeExpression
javascript{var date = new Date();(date.getMonth()+2) + '/' + date.getDate() + '/' + date.getFullYear();}
$InDate
But this is worthless, since it will come up with "month 13" in December, instead of January.
Even though the following js code produces a valid date 30 days in the future, I can't figure out how to store this as an expression in Selenium ...
- Code:
var numberOfDaysToAdd = 30;
inDate.setDate(inDate.getDate() + numberOfDaysToAdd);
var dd = inDate.getDate();
var mm = inDate.getMonth() + 1;
var y = inDate.getFullYear();
var inDateFormatted = dd + '/'+ mm + '/'+ y;
document.write(inDateFormatted);
How can I reliably add 30 days or so to a date when picking a date field?
SOLVED -
I managed to do it this way:
- Code:
storeEval
javascript{var dates = new Date();var day = dates.getDate();if (day < 10){day = '0' + day;} month = dates.getMonth() + 2;if (month = 13 ){month = month - '12';}var year = dates.getFullYear();day + '/' + month + '/' + year}
FutureDate
Then you can call it with
- Code:
type
input_field_name
${FutureDate}
Permissions in this forum:
You cannot reply to topics in this forum