I am trying to verify if the state of a check box is checked or not if the state is false click if not do something else. Should i use .getAttribute() or .getState(). I think I should use get state.
WebElement checkbox = driver.findElement(By.name("companyOptionsForm:mandateVerificationTotals"));
if (checkbox.getState() == true) {
//do something
} else if (checkbox.getState()== false) {
//do something
}
The HTML of the Check box
< input name = "companyOptionsForm:mandateVerificationTotals"
type = "checkbox"role = "checkbox"aria - checked = "true"
class = "dijitReset dijitCheckBoxInput"data - dojo - attach - point = "focusNode"
data - dojo - attach - event = "ondijitclick:_onClick"
value = "on"tabindex = "0"id = "mandateVerificationTotals"
checked = "checked" style = "user-select: none;" >
However when i use .getState() eclipse shows a red line under it.
Aucun commentaire:
Enregistrer un commentaire