[英]assert selenium getAllSelectedOptions() using assertJ
我無法做到這一點,到目前為止能夠使用getFirstSelectedOption().getText()
從多個選擇元素斷言所選項目。
是否可以使用assertJ斷言getAllSelectedOptions()
getTex()
? 我可以通過foreach
循環遍歷getAllSelectedOptions()
我知道我可以使用getAllSelectedOptions().get(0).getText())
並為所有選定項增加get(x)。 但是有沒有優雅的解決方案(不使用索引)?
你可以嘗試這樣的事情:
//identify a common locator which identifies multiple items and store in a list
List<WebElements> allItems=driver.findElementsById("xa");
System.out.println("The total number of radio buttons are:" +allItems.size());
for(WebElement eachItem:allItems)
{
System.out.println(eachItem.getText());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.