成都创新互联网站制作重庆分公司

selenium学习:定位一组元素

文件名:checkbox.html

创新互联主要从事成都网站建设、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务萝北,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575




Checkbox





		

Checkbox

      checkbox1
checkbox2
checkbox3      

文件名: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://cxhlcq.com/article/iehode.html

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部