Webdriver Script065 : Picking Date from Calendar

/* Script Summary

 Title  : Webdriver Script065 : Picking Date from Calendar
 Author : QA Masterz
 Actions  :

 1. Set the Base URL to "http://www.redbus.in".
 2. Open the Calendar.
 3. Select the Date
 4. Wait for 5 seconds.

 */


package com.gaurav.webdriver.junit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class s066_DatePicker {

    // Declaring variable 'webDriver' of WebDriver Type
    WebDriver webDriver;

    // Declaring baseURL variable of String Type
    String baseUrl;

    @Before
    public void startUp() throws Exception {

        // Initializing FireFox Driver
        webDriver = new FirefoxDriver();

        // Assigning URL to variable 'baseUrl'
        baseUrl = "http://www.redbus.in";
    }

    @Test
    public void tests066_DatePicker() throws Exception {

        // Open the link
        webDriver.get(baseUrl);

        // Maximize browser window
        webDriver.manage().window().maximize();

        // Open the Calendar
        webDriver.findElement(By.id("calendar")).click();

        // Select the Date
        webDriver
                .findElement(
                        By.xpath(".//*[@id='rbcal_calendar']/div/div/table[1]/tbody/tr[4]/td[3]"))
                .click();

        // Wait for 5 seconds
        Thread.sleep(5000);
    }

    @After
    public void shutDown() throws Exception {

        // This will close the browser
        webDriver.quit();
    }

}