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. I need to admit that that is one wonderful insight. It surely gives a company the opportunity to have in around the ground floor and really take part in making a thing special and tailored to their needs. There are so many fun and exciting things to do and experiences around the world that I thought I ‘d put together a list of favorite Things to do for all travelers.

    ReplyDelete
  6. King David Moving & Storage is a Chicago moving companythat provides residential and commercial moversservices to our local community. Our moving services in Chicago are specialized to assist you and your family to move from one location to another with the assisting of our best movers that are professionally trained by us as Chicago Movers. We have been awarded for our customer service excellency, because customer satisfaction is one of our top priorities. Thus, We take pride in our local movers and success in business because of providing the reasonable rates as well as quality of service and this has been reflected on highly positive reviews.

    ReplyDelete