I am working on selecting checkboxes(2) randomly using selenium Python. After selection is done, I want to verify the number of checked checkboxes. How to do that?
Below is my code:
checkboxes = driver.find_elements(By.XPATH, "//*[@type='checkbox']")
print(len(checkboxes))
for x in range(2):
opt = random.choice(checkboxes)
if opt.is_enabled():
opt.click()
is_selected()method which can used to check if a checkbox is selected or not. You can refer to this post - stackoverflow.com/questions/14442636/…