This is the HTML of the checkbox I'm trying to select

I can locate the checkbox using xPath but cannot verify if this checkbox is selected using the isSelected() method.

I'm using the xPath as //div[@class='Form-field Form-field--spacer']//label[@for='RememberMe']. I need to first verify if the checkbox is selected

I tried to verify it using the isSelected() method, but there is no success with it.

  • @K. K Are you able to uncheck the checkbox? If yes, Does class value in span changes? Current class value is-"Checkbox is-active"
    – JAINAM
    Jul 16, 2020 at 11:06

1 Answer 1


Your xpath defines a label. Not a check-box. This is why you cannot check if it is selected or not. I would suggest to change your xPath to //input[@type='checkbox'][@id='RememberMe'].

  • The mentioned xPath is not found, so it is throwing org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of error. Dec 10, 2018 at 10:33
  • @K.K is your check-box displayed (i.e. visible)?
    – Alexey R.
    Dec 10, 2018 at 10:37
  • Yes, by default the checkbox is selected. Dec 10, 2018 at 10:41
  • also irrespective of the checkbox checked or unchecked the attribute checked is always set as Checked. Dec 10, 2018 at 11:00
  • @K.K the latter is okay. As per specification, checked attribute Specifies that an <input> element should be pre-selected when the page loads (for type="checkbox" or type="radio")
    – Alexey R.
    Dec 10, 2018 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.