is_selected()检查是否选中该元素,一般针对单选框,复选框,返回的结果是bool 值,
以百度登录页面为案例,来验证"下次自动登录"是否勾选,默认是勾选的,返回的结
果应该是True,见实现的代码和输出:
# -*-coding:utf-8-*-
from selenium import webdriver
import time as t
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.baidu.com')
driver.find_element_by_id('u1').find_element_by_class_name('lb').click()
t.sleep(3)
driver.find_element_by_id('TANGRAM__PSP_10__footerULoginBtn').click()
t.sleep(3)
print(driver.find_element_by_id('TANGRAM__PSP_10__memberPass').is_selected())
driver.quit()