Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium IDE: How do I get today's date?

I'm testing my web application using Selenium IDE. There are test cases in which I have to assert that today's date appears on the page. I cannot hard code today's date in the test because today's date changes every day. How do I get the current day, month & year in Selenium IDE?

like image 351
snakile Avatar asked Jul 05 '11 11:07

snakile


1 Answers

Not sure what format your date is in, but you could do something like this:

<tr> 
        <td>storeEval</td> 
        <td>var d=new Date(); d.getDate()+'-'+((d.getMonth()+1)) 
+'-'+d.getFullYear();</td> 
        <td>date2</td> 
</tr> 
<tr> 
        <td>echo</td> 
        <td>${date2}</td> 
        <td></td> 
</tr> 
like image 81
highlycaffeinated Avatar answered Oct 11 '22 21:10

highlycaffeinated