2016-12-05 29 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

相關問題