<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover" type="button" role="button" aria-disabled="false">
<span>
<br/>
For use to protect against or prevent actual or potential fraud, unauthorized transactions,claims or other liability.
</span>
<br/>
<br/>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
</div>
<span align="center"> Selection of this option will automatically log you out of the system.</span>
</div>
</div>
我有兩個按鈕相同的按鈕類名稱。如何找到第一個按鈕並單擊它。這些唯一的區別在於我嘗試過的跨文本,但它沒有解決。硒web驅動程序查找元素
List<WebElement> buttons=driver.findElements(By.className("ui-dialobuttonset"));
buttons.get(0).click().
力工作
當html源代碼不可用時很難得到原因。請張貼源代碼部分。否則,我只能建議你嘗試'By.xpath',因爲'By.className'不適合你。 – Quinn