AttributeError: 'WebElement' object has no attribute 'checked'
AttributeError: 'WebElement' object has no attribute 'checked'
得到以下块的:AttributeError: 'WebElement' object has no attribute 'checked'
错误:
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
如您所见,我这里有一个 table 属性...但无法识别。
Attributes can be seen here
有人可以帮我吗?提前致谢。
要获取 Web 元素属性,您应该使用 .get_attribute()
方法。
试试这个:
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')
得到以下块的:AttributeError: 'WebElement' object has no attribute 'checked'
错误:
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
如您所见,我这里有一个 table 属性...但无法识别。
Attributes can be seen here
有人可以帮我吗?提前致谢。
要获取 Web 元素属性,您应该使用 .get_attribute()
方法。
试试这个:
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')