0

I am trying to access the following HTML checkbox for a button click:

<input type="checkbox" data-ng-value="sf.name" data-ng-model="sf.checked" ng-click="ec.onStateFilterChanged(sf)" title="Select a state" class="ng-untouched ng-valid ng-dirty ng-valid-parse" value="Arizona">

using:

state = driver.find_element_by_xpath("input[@type='checkbox']").click()

but keep getting error:

selenium.common.exceptions.NoSuchElementException: Message: 

what might be the element path I am looking for in order to select the checkbox?

0

1 Answer 1

1

Your xpath is most likely incorrect - you need to enter // before the element as this will find all (single slash / will work here too though as you are only trying to find one element and it will find the first match)

Try one of the following:

state = driver.find_element_by_xpath("//input[@type='checkbox']").click()

OR

state = driver.find_element_by_css_selector("input[type='checkbox']").click()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.