0
我一直在嘗試獲取頁面中所有複選框內的標籤值,到目前爲止,我一直在使用此代碼來自動執行下面的HTML。如何獲得所有複選框的文本(標籤)
JAVA:
List<WebElement> allCBox = driver.findElements(By.xpath("//input[@type='checkbox']"));
for(WebElement checkbox : allCBox) {
System.out.println("--- "+checkbox.gettext());
}
HTML:
<html>
<p> Regions:
south <input type="checkbox" name="south" value="south">
british <input type="checkbox" name="british" value="british">
north <input type="checkbox" name="north" value="north">
southeast <input type="checkbox" name="southeast" value="southeast">
west <input type="checkbox" name="west" value="west">
Spanish <input type="checkbox" name="spanish" value="spanish">
europian <input type="checkbox" name="europian" value="europian">
northeast <input type="checkbox" name="northeast" value="northeast">
</p>
</html>
您需要標記您的嵌入式html;它沒有正確顯示。 – 2013-05-10 10:19:41