Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

[SOLVED] Need to add arbitrary number of days to date in date picking fields ...

View previous topic View next topic Go down

[SOLVED] Need to add arbitrary number of days to date in date picking fields ...

Post by kelt65 on 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)

kelt65

Posts : 2
Join date : 2012-10-30

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum