【发布时间】:2018-05-07 11:23:16
【问题描述】:
根据场景,如果复选框已经被选中,那么我只需要打印文本,如果复选框没有被选中,那么我需要点击复选框。
//-Check sandbox test client checkbox is already checked or not if not then tick on checkbox
boolean sandboxClientCheckbox = driver.findElement(By.xpath("//div[@class='eplChkBoxWrapper']//label[@id='acChkSandboxClientForLbl']")).isSelected();
System.out.println("Check checkbox value " +sandboxClientCheckbox);
if(sandboxClientCheckbox == true) {
Utils.pauseTestExecution(3);
System.out.println("Checkbox is already checked ");
} else {
driver.findElement(By.id("acChkSandboxClientForLbl")).click();
}
HTML标签是
<div class="eplChkBoxWrapper">==$0
<input type="checkbox" id="acChkSandboxClient" class="eplChkBox">
<label id="acChkSandboxClientForLbl" for="acChkSandboxClient">
::after
</label>
谁能帮帮我?如何在执行时检查此复选框是否已选中?我共享了 DOM 元素。
【问题讨论】:
-
使用处于 unchecked 和 checked 状态的元素的 HTML 更新问题。
-
选中==$0 并且没有检查==$0@DebanjanB 对此有何更新?