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