How to display all the values in auto drop down list using selenium web driver when it is developed using tag.
My code
driver.get("https://www.yatra.com/");// URl of yatra
String origin ="(//input[@name='flight_origin_city'])[1]";// text box for entering origin
driver.findElement(By.xpath(origin)).sendKeys("Bangalore");
String destination = "(//input[@name='flight_destination_city'])[1]";// text for entering destination
driver.findElement(By.xpath(destination)).sendKeys("M");
List<WebElement> lists= driver.findElements(By.xpath("(//div[@class='viewport'])[2]")); // this is the div where all the values are present .
for (int i=0; i<lists.size();++i){
System.out.println(lists.get(i).getText());// getting the text for all the values.
}
Aucun commentaire:
Enregistrer un commentaire