Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Regarding Alert Interface
Fri Feb 24, 2017 2:00 pm by karthikeyakumar

» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

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