从与不从下拉菜单中硒 - 下拉
中的字段,这是我的代码:
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