1

Possible Duplicate:
Selenium checkbox attribute “checked”

I am testing an application implemented in ExtJs.

The checkboxes and radio buttons are implemented as buttons.

I am trying to get the state of the checkbox if it is checked or not using Selenium.

Here is the implementation:

<td id="checkboxfield-1258-bodyEl" class="x-form-item-body x-form-cb-wrap" role="presentation" colspan="3" style="width: 100%;">
<input id="checkboxfield-1258-inputEl" class="x-form-field x-form-checkbox" type="button" hidefocus="true" autocomplete="off" aria-invalid="false" data-errorqtip="" style="-moz-user-select: text;">
<label id="checkboxfield-1258-boxLabelEl" class="x-form-cb-label x-form-cb-label-after" for="checkboxfield-1258-inputEl">Use External tag</label>
</td>

Can someone please guide me how can I check the status ?

Thanks, Harpal

Community
  • 1
  • 1
user1710861
  • 413
  • 6
  • 9

1 Answers1

0

first possible solution: have you tried this isSelected() method in the API?

isChecked = e.findElement(By.tagName("input")).Selected;

isChecked = e.findElement(By.tagName("input")).isSelected;

see some additional info here second possible solution: Here is the function getting certain properties an element:

public String jsGetColor(String css){

        JavascriptExecutor js = (JavascriptExecutor) driver;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("var x=$(\'"+css+"\');");
        stringBuilder.append("return x.css('color')");
        String res= (String) js.executeScript(stringBuilder.toString());
        return res;

    }

Hope this helps you)

Community
  • 1
  • 1
eugene.polschikov
  • 7,254
  • 2
  • 31
  • 44