How can I check if a checkbox is checked in Selenium Python WebDriver?

python, selenium-webdriver

Solution

I found another way that works, but using javascript inside.

def is_checked(self, driver, item_id):
  checked = driver.execute_script(
    f"return document.getElementById('{item_id}').checked"
  )
  return checked

Problem

I've been searching a week how check if a checkbox is checked in Selenium WebDriver with Python, but I find only algorithms from JAVA. I've read the WebDriver docs and it doesn't have an answer for that. Anyone have a solution?

Original source