Automation Using Selenium Webdriver
Showing posts with label How to get from dropdown List in Cities. Show all posts
Showing posts with label How to get from dropdown List in Cities. Show all posts

Friday, 14 October 2016

How to get from dropdown List in Cities



Print all dropdown cities www.goindigo.com

package com.Test.web;

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.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class PrintCitesDropDown {
    static WebDriver driver;
public static void main(String[] args) throws Exception {
Thread.sleep(5000);
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// driver=new FirefoxDriver();
driver=new ChromeDriver();
driver.manage().window().maximize();
//Print DropDown list Cities
driver.get("https://www.goindigo.in/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[@id='roundWay']/form/ul/li[1]/input[1]")).click();
List<WebElement>cities=driver.findElements(By.xpath(".//*[@id='roundWay']/form/ul/li[1]/div/ul/li"));
System.out.println("Number of cities:"+cities.size());
for (int i = 0; i < cities.size(); i++) {
System.out.println(i+1+")city name:"+cities.get(i).getText());

}

}

}
OUTPUT::