mercredi 17 août 2016

How to check state of a checkbox if it doesn't have "checked" attribute?

I'm trying to check the state of a checkbox using Selenium Webdriver or Javascript but having done a lot of research I still can't do it.

My problem is: the checkbox doesn't have "checked" attrubute:

<input type="checkbox" name="site[new_sign_up]" id="site_new_sign_up" value="1">

For regular normal checkboxes I use the next string to detect if a checkbox is checked or not:

if (checkbox.GetAttribute("checked") != null && checkbox.GetAttribute("checked").Equals("true"))

I know it could be done with JS:

$get("isAgeSelected").checked == true

But still I can't do it as my checkbox doesn't have "checked" property.

If using selenium I check "Selected" property of element it also doesn't tell me the truth of checkbox state.

Any suggestions of how to do it? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire