Below steps I need to do:
- check if the checkbox is ticked or not.
a)If it is ticked then follow certain steps
b)If it is not ticked then tick the check box and follow the same steps in a)
This is my HTML code:
<td style="width: 4.5%; padding-left: 2px;" class="heading" data-bind="css: selected() ? 'headingSelected' : 'heading'">
<img title="Click to show all employees" data-bind="click: _apps.expandUnExpand, visible: !expanded()" class="clickable" src="/Content/Images/plus.gif" style="display: none;">
<img title="Click to hide all employees" data-bind="click: _apps.expandUnExpand, visible: expanded()" class="clickable" src="/Content/Images/minus.png">
<img title="Click To Select Application" data-bind="click: _apps.selectUnSelect, visible: !selected() && !_apps.readOnly() " class="clickable" src="/Content/Images/unchecked.png">
<img title="Click To Unselect Application" data-bind="click: _apps.selectUnSelect, visible: selected() && !_apps.readOnly() " class="clickable" src="/Content/Images/checked.png" style="display: none;">
</td>
Below is my code:
if(driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).isEnabled()) //Xpath when checbox is ticked
{
System.out.println("checkbox is selected");
driver.findElement(By.xpath("//button[text()='Add to ACL']")).click();
}
else
if(driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).isEnabled()) //xpath when checkbox is not ticked
{
System.out.println("checkbox is unselected");
driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).click();// tick the checkbox
driver.findElement(By.xpath("//button[text()='Add to ACL']")).click();
}
If I try with single if the code works but when I combine both the If(if and else if) code dosn't work
Aucun commentaire:
Enregistrer un commentaire