coding:utf-8
引用webdriver
from selenium import webdriver
用来查找页面元素的类
from selenium.webdriver.common.by import By
睡眠时间
import time
path = r’D:\webdriver\chromedriver.exe’
打开浏览器
wd = webdriver.Chrome(executable_path=path)
wd.set_page_load_timeout(5)
如果页面3秒钟都还没有加载完成的话
那么我们继续尝试去做其它控件的操作
wd.get(‘http://192.168.1.251:9012/ui/test/ex16’)
time.sleep(2)
ele_all = wd.find_elements_by_xpath(’//input[@name=“fa”]/following-sibling::div’)
for ele_fa in ele_all:
if ‘checked’ in ele_fa.get_attribute(‘class’):
continue
time.sleep(2)
ele_fa.click()
time.sleep(10)
wd.quit()