[quote:380xxgsf]How to make use of the method selectByIndex, selectByValue to select an option from dropdown[/quote:380xxgsf]
you usage is fine.
[quote:380xxgsf]2. I have written the below code to select the Departure and destination cities from drop downs in makemytrip.com and its not doing as expected.
[/quote:380xxgsf]
try this. just send "enter".
[code:380xxgsf]package com.soapuitutorial.propertie;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Handling_dropdowns {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.makemytrip.com/");
WebElement dropdown = driver.findElement(By.id("class_selector"));
// List<WebElement> All=driver.findElements(By.id("class_selector"));
Select s = new Select(dropdown);
s.selectByValue("PE");
driver.findElement(By.id("from_typeahead1")).sendKeys(
"New Delhi"+Keys.ENTER);
// s.selectByVisibleText("Bangalore, India (BLR)");
driver.findElement(By.id("to_typeahead1")).sendKeys("Goa"+Keys.ENTER);
// s.selectByVisibleText("Goa, India (GOI)");
}
}[/code:380xxgsf]