從與不從下拉菜單中硒 - 下拉
中的字段,這是我的代碼:
public class MyFirst {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\kunal.bhaskar\\Downloads\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "https://www.goindigo.in";
driver.get(baseUrl);
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[1]/input[1]")).clear();
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[1]/input[1]")).click();
Select from = new Select(driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[1]/input[1]")));
from.selectByVisibleText("Delhi");
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[2]/input[1]")).click();
Select to = new Select(driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[2]/input[1]")));
to.selectByVisibleText("Patna");
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[3]/input")).click();
Select adult = new Select(driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/ul/li[3]/div/div[1]/label[2]/select")));
adult.selectByVisibleText("2");
driver.findElement(By.xpath("//*[@id=\"depart-date\"]")).clear();
driver.findElement(By.xpath("//*[@id=\"depart-date\"]")).sendKeys("18 Oct 2017");
driver.findElement(By.xpath("//*[@id=\"return-date\"]")).clear();
driver.findElement(By.xpath("//*[@id=\"return-date\"]")).sendKeys("28 Oct 2017");
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[1]/div/div/div/ul/li[2]/div/div[1]")).click();
driver.findElement(By.xpath("//*[@id=\"roundWay\"]/form/div[2]/button")).click();
}
這不是一個下拉 – iamsankalp89
那麼如何從給出的選項 – Kunal
選擇任何一個城市,我會提供ü代碼 – iamsankalp89