Pages

Search This Blog

Monday, July 19, 2010

How to store date in dd-mm-yy format in Selenium

There are some cases while we search the data based on start and end date based on date format dd-mm-yy.

=======

<tr>
<td>store</td>
<td>javascript{var d = new Date();var curr_date = d.getDate()-2;if(curr_date.toString().length!=2) curr_date = '0'+curr_date ;var curr_month = d.getMonth(); curr_month = curr_month + 1;if(curr_month.toString().length!=2) curr_month= '0'+curr_month;curr_date + '-'+ curr_month + '-'+10;}</td>
<td>start_date</td>
</tr>
<tr>
<td>store</td>
<td>javascript{var d = new Date();var curr_date = d.getDate();if(curr_date.toString().length!=2) curr_date = '0'+curr_date ;var curr_month = d.getMonth(); curr_month = curr_month + 1;if(curr_month.toString().length!=2) curr_month= '0'+curr_month;curr_date + '-'+ curr_month + '-'+10;}</td>
<td>end_date</td>
</tr>
<tr>
<td>echo</td>
<td>${start_date}</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${end_date}</td>
<td></td>
</tr>


This gives the result in below format
Start date : 17-07-10
End date : 19-07-10


9 comments:

  1. How to handle on load events? i have a confirmation box that is an on load event. can u please tell me how to close that box? i am using eclispe an Java

    ReplyDelete
  2. You can somehow manage to handle alerts with below code

    assertTrue(selenium.isAlertPresent());

    verifyEquals("This is message on alert", selenium.getAlert());
    //click|oneAlert|
    selenium.click("oneAlert");
    Hope this will work for you

    ReplyDelete
  3. How to select a date from the calendar control while recording in selenium ??????

    ReplyDelete
  4. how do you get the date format as dd/mm/yyyy and calculate no. of days between 2 dates in selenium?

    ReplyDelete
  5. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  6. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  7. Well explained. Got to learn new things from your Blog on Appium.
    Appium training in chennai

    ReplyDelete
  8. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

    ReplyDelete