can you please help me in checking/unchecking the check box from below screenshot.
This is xpath which i used...........
d.findElement(By.xpath(OR.getProperty(b))).getAttribute("type");
use this to click, what is the problem?
d.findElement(By.xpath(OR.getProperty(b))).click();
Keyword function: "checkCheckBox"
Before clicking on check box we are supposed to validate whether it is NULL or any value exists. To validate this, we tried to save that value in as String as below.
try {
String checkbox = d.findElement(By.xpath(OR.getProperty(b))).getAttribute("type");
if (checkbox == null) {
d.findElement(By.xpath(OR.getProperty(b))).click();
}
} catch (Exception e) {
return Constants.Fail + "---" + e.getMessage();
}
return Constants.pass;
}
send a full screenshot of HTML of the checkbox. in above checkbox, the screenshot is cut from the right.
try this and tell me the result
try {
String checkbox = d.findElement(By.xpath(OR.getProperty(b))).getAttribute("selected");
if (checkbox == null) {
d.findElement(By.xpath(OR.getProperty(b))).click();
}
} catch (Exception e) {
return Constants.Fail + "---" + e.getMessage();
}
return Constants.pass;
}
This is working fine. can you please let me know from where did you use attribute "selected" as this is not populated in HTML of checkbox
I remember "selected" from when I learned php and html. it works with radio button too.