答案 0 :(得分:0)
使用索引尝试下面的xpath: -
// for first element
(//div[@id = 'virtual_description']/a)[1]
// for second element
(//div[@id = 'virtual_description']/a)[2]
// for third element
(//div[@id = 'virtual_description']/a)[3]
希望它会对你有所帮助.. :)
答案 1 :(得分:0)
尝试以下方法:
List<WebElement> elem = driver.findElements(By.cssSelector("div#virtual_description[style*='visibility: visible']>a.fr-btn"));
for(int i=0;i<elem.size();i++){
try {
if(elem.get(i).isDisplayed()){//u can try isEnabled() here
elem.get(i).click();
break;
}
} catch (Exception e) {
continue;
}
}
希望这有效。