Current date calculation in selenium web driver

Here i need to select “From date” as current date and “To date” is next date …
In my calendar sundays are unselectable(disable) mode….canu u provide me a sample code for this scenario…for your reference  i will send the URL “http://www.hss.com/hire/p/hydraulic-breaker-petrol”

Add Comment
  • 2 Answer(s)

    its very helpfull if u give me the proper code

    Train Answered on July 13, 2015.
    Add Comment

    Calendar cal = Calendar.getInstance();
    int todayDate = cal.get(Calendar.DAY_OF_MONTH);
    int tomorrowDate = todayDate+1;

    String todayStr = String.valueOf(todayDate);
    String tomorrowStr = String.valueOf(tomorrowDate);

    driver.get(“http://www.hss.com/hire/p/hydraulic-breaker-petrol”);

    WebElement start = driver.findElement(By.id(“hireFromDate”));
    start.click();

    WebElement today = driver.findElement(By.xpath(“.//*[@id=’ui-datepicker-div’]//a[contains(text(),'” + todayStr + “‘)]”));
    today.click();

    WebElement doneButton = driver.findElement(By.xpath(“.//button[contains(text(),’Done’)]”));
    doneButton.click();

    WebElement end = driver.findElement(By.id(“hireToDate”));
    end.click();

    WebElement tomorrow = driver.findElement(By.xpath(“.//*[@id=’ui-datepicker-div’]//a[contains(text(),'”+tomorrowStr+”‘)]”));
    tomorrow.click();

    WebElement doneButtonEnd = driver.findElement(By.xpath(“.//button[contains(text(),’Done’)]”));

    doneButtonEnd.click();

    And it will be last answer for you if you won’t mark this question as ANSWERED

    And previous questions too.

    Reviewer Answered on July 13, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.