更新时间:2023-08-22 20:53:52
尝试以下代码,您会错过Select
类以选择下拉列表
Try this code, You miss the Select
class to select drop down
driver.get("http://live.guru99.com/index.php/");
String title=driver.getTitle();
String expectedTitle="Home page";
System.out.println("The title of the webPage is "+title);
expectedTitle.equalsIgnoreCase(title);
System.out.println("Title is verified");
driver.findElement(By.xpath("//a[text()='Mobile']")).click();
String nextTitle=driver.getTitle();
System.out.println("The title of next page"+nextTitle);
String nextExpectedTitle="pageMobile";
nextExpectedTitle.equalsIgnoreCase(nextTitle);
System.out.println("The next title is verified");
Select s=new Select(driver.findElement(By.xpath(".//*[@id='top']/body/div[1]/div/div[2]/div/div[2]/div[1]/div[3]/div[1]/div[1]/div/select")));
s.selectByVisibleText("Name");