import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--allow-file-access-from-files")
driver = webdriver.Chrome(options=options)
driver.get("file:///Users/wangshuheng/PycharmProjects/selenium/单选框(Radio)复选框(CheckBox).html")
# 1.复选框
# 方式1
el1 = driver.find_element_by_xpath("/html/body/input[1]").click()
# 方式2
el2 = driver.find_element_by_xpath("/html/body/input[2]").send_keys(Keys.SPACE)
# 2.单选框
# 方式1
el3 = driver.find_element_by_xpath("/html/body/p/input[1]").click()
# 方式2
time.sleep(3)
el4 = driver.find_element_by_xpath("/html/body/p/input[2]").send_keys(Keys.SPACE)
el5 = driver.find_element_by_xpath("/html/body/input[1]")
el5.click()
# 判断是否勾选
res1 = el5.is_selected()
print(res1)