html code:
input type="checkbox" class="checkbox_one" disabled
if checkbox is not disable text is not coming.
Assert.assertTrue(webelemt.getAttribute("innerHTML").contains("disabled"));
You can use....
ele = driver.find_element_by_class_name('checkbox_one')
if ele.is_selected():
// do something
else:
// do something
You can call .getAttribute
method to have a condition where it will check for it's content and if that is not empty, assert should be pass, if empty assert should be fail.
Code:
WebElement webelemt = driver.findElement(By.xpath("//span[@title='fieldItem']//preceding-sibling::input"));
String checkBoxStatus = "";
if (!webelemt.getAttribute("disabled").isEmpty() && webelemt.getAttribute("disabled").contains("disabled")) {
System.out.println("Disabled must be present");
checkBoxStatus = "disabled";
Assert.assertTrue(true);
}
else {
System.out.println("Should not it be enabled ? or do we need if-else to handle that part as well.");
Assert.assertTrue(false);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.