我一直在尝试在页面中的所有复选框中获取标签值,到目前为止,我一直在使用此代码来自动化下面的 HTML。
爪哇:
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>