0
下面我需要做的步驟:複選框不硒正常工作
- 檢查,如果該複選框被選中與否。
a)如果它被選中,然後按照一定的步驟
B)如果沒有打勾,然後點擊複選框,並按照一)
這是我的HTML代碼相同的步驟:
<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>
下面是我的代碼:
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(if和else if)代碼不起作用
這是我的HTML代碼: – suchi