Got the: AttributeError: 'WebElement' object has no attribute 'checked'
error for the following block:
wait = WebDriverWait (driver, 15)
element = wait.until(EC.visibility_of_all_elements_located((By.XPATH,"XYZ")))
for i in element:
if 'true' == i.checked:
print('Step 33. Auto update button is ON - PASS')
else:
print('Step 33. Auto update button failed to switch - PASS')
pass
As you can see I have a table here with the attributes... but is not recognized.
Can anyone help me with that? Thanks in advance.
CodePudding user response:
To get a web element attribute you should use .get_attribute()
method.
Try this:
wait = WebDriverWait (driver, 15)
element = wait.until(EC.visibility_of_all_elements_located((By.XPATH,"XYZ")))
for i in element:
if 'true' == i.get_attribute("checked"):
print('Step 33. Auto update button is ON - PASS')
else:
print('Step 33. Auto update button failed to switch - PASS')