How to find out if a checkbox is checked in Selenium

You can’t reliably use the checked attribute for this, as this only indicates whether that attribute has been set in code (HTML or JavaScript), not whether the user has checked the checkbox. Instead, you need to use the isSelected() method.

Java

boolean isChecked = driver.findElement(By.id("myInput")).isSelected();

Python

is_checked = driver.find_element_by_id("myInput").is_selected()

C#

bool isChecked = driver.FindElement(By.Id("myInput")).Selected;