2016-12-05 54 views

回答

0

如果你想从下拉列表中当前选定的文本,你可以使用“getFirstSelectedOption”的方法,如下图所示:

String city; 
Select dropdown = new Select(driver.findElement(By.id("city")));  //Selects the dropdown menu 
dropdown.selectByValue(cityName); //selects Ajax as the city from the Dropdown menu 
city = dropdown.getFirstSelectedOption(); 

请让我知道,如果我误解了你的问题。

+0

谢谢,它的作品! –

+0

太好了。不用谢。请您接受我的答案,并将其标记为有用,如果它按照您的期望工作:-)。 – Mahipal

相关问题