import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MakeMyTrip {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get(“http://www.makemytrip.com/”);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath(“//span[input[@tabindex=’4′]]//a”)).click();
        List<WebElement> cities = driver.findElements(By.xpath(“//li[@class=’ui-menu-item’]”));
        System.out.println(“Number of cities : “+cities.size()); //this will take only those which are visible in 1st click
        for(int i=0; i<cities.size(); i++){
            System.out.println(i+1+”) city name: “+cities.get(i).getText());
        }
        driver.close();
    }
}

output- 

Number of cities : 47
1) city name: New Delhi, India (DEL)
2) city name: Mumbai, India (BOM)
3) city name: Bangalore, India (BLR)
4) city name: Goa, India (GOI)
5) city name: Chennai, India (MAA)
6) city name: Kolkata, India (CCU)
7) city name: Hyderabad, India (HYD)
8) city name: Pune, India (PNQ)
9) city name: Ahmedabad, India (AMD)
10) city name: Cochin, India (COK)
11) city name: Jaipur, India (JAI)
12) city name: Dubai, UAE (DXB)
13) city name: Singapore, Singapore (SIN)
14) city name: Bangkok, Thailand (BKK)
15) city name: New York, US – All Airports (NYC)
16) city name: Kuala Lumpur, Malaysia (KUL)
17) city name: London, UK – All Airports (LON)
18) city name: Hong Kong, China (HKG)
19) city name: Doha, Qatar (DOH)
20) city name: Colombo, Sri Lanka (CMB)
21) city name: Agartala, India (IXA)
22) city name: Agatti Island, India (AGX)
23) city name: Ahmedabad, India (AMD)
24) city name: Aizawl, India (AJL)
25) city name: Allahabad, India (IXD)
26) city name: Amritsar, India (ATQ)
27) city name: Aurangabad, India (IXU)
28) city name: Bagdogra, India (IXB)
29) city name: Bangalore, India (BLR)
30) city name: Belgaum, India (IXG)
31) city name: Bellary, India (BEP)
32) city name: Bhavnagar, India (BHU)
33) city name: Bhopal, India (BHO)
34) city name: Bhubaneshwar, India (BBI)
35) city name: Bhuj, India (BHJ)
36) city name: Calicut, India (CCJ)
37) city name: Chandigarh, India (IXC)
38) city name: Chennai, India (MAA)
39) city name: Cochin, India (COK)
40) city name: Coimbatore, India (CJB)
41) city name: Dehradun, India (DED)
42) city name: Dharamshala, India (DHM)
43) city name: Dibrugarh, India (DIB)
44) city name: Dimapur, India (DMU)
45) city name: Diu, India (DIU)
46) city name: Gaya, India (GAY)
47) city name: Goa, India (GOI)

 

Source: http://selenium-makeiteasy.blogspot.com