文件名:test10.py
from selenium import webdriver
import os,time
driver = webdriver.Chrome()
file_path='file:///'+os.path.abspath('checkbox.html')
driver.get(file_path)
inputs = driver.find_elements_by_tag_name('input')
for i in inputs:
if i.get_attribute('type')=='checkbox':
i.click()
time.sleep(1)
driver.quit()
test10.py代码中的意思:访问checkbox.html
通过tag方法访问checkbox.html中所有的input元素
找到input元素之后,通过判断input属性中的"chekcbox"属性,从而定位出需要定位的一组元素
分享文章:selenium学习:定位一组元素
网页链接:
http://scjierui.cn/article/iehode.html