Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
kelt65
Posts : 2
Join date : 2012-10-30

[SOLVED] Need to add arbitrary number of days to date in date picking fields ... Empty [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:

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}


Last edited by kelt65 on Wed Oct 31, 2012 3:29 am; edited 1 time in total (Reason for editing : post solution)
Back to top
Permissions in this forum:
You cannot reply to topics in this forum