【发布时间】:2021-10-08 00:36:32
【问题描述】:
https://www.goibibo.com/hotels/ Image
我想使用 selenium 选择一个城市,但它不起作用 我尝试过使用 xpath、css 选择器、id、className。\
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Goibibo {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver_2\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
//Goto Url Goibibo.com
driver.get("https://www.goibibo.com/hotels/");
System.out.println("WWW.GOIBIBO.COM");
//Select Country India
driver.findElement(By.xpath("//input[@name='CountryType']")).click();
System.out.println("Selected Country India");
// Click on Search Bar
driver.findElement(By.id("downshift-1-input")).click();
System.out.println("Clicked On Search Bar");
//Select Mysore City
driver.findElement(By.xpath("//*[@id=\"downshift-1-menu\"]/div/ul/li[2]/img")).click();;
}
}
【问题讨论】:
标签: selenium selenium-webdriver css-selectors selenium-chromedriver dropdown