Check AngularJS checkbox with Selenium

Published

HTML Source here

It seems trivial, but after hours of attempts I cannot manage to check this checkbox using Selenium. I am able to select the element no problem, and have even been able to ‘highlight’ (see code snippet below) it by sending Keys.RETURN to the element, but on attempting to click it, nothing happens. Perhaps someone has an idea?

What I have tried already:

  • Using with WebDriverWait
  • Using multiple and different combinations of .click()/.send_keys(Keys.RETURN)
  • Just about every combination of XPATH/css selector/id/name/classname/text that Selenium would accept for the element, and all of its children and most of its parents (including spans/labels, and the text inside the label itself).
  • Directly clicking the element/label coordinates using actions (nothing happens, even when I can 100% confirm it is clicking the right spot by using context_click()).
  • Using execute_script to change the "checked" attribute to True (the checkbox appears checked, but it is clear it is only client side as a box that is supposed to render when it is actually clicked doesn’t).
  • Using execute_script to change the class to ‘ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched’

Here is the code that I feel got me the closest (it is ‘highlighting’ the box as seen here)

browser.find_element(By.ID, "sp_formfield_other").send_keys(Keys.RETURN)

Source: Angular Questions

Published
Categorized as angular, html, python, selenium Tagged , , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq