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)
原生radio的控制
wd.find_element(By.XPATH, “//input[@name=‘sex2’][2]”).click()
点击自定义radio
wd.find_element(By.CSS_SELECTOR,".proxy_srh .layui-form-radio:nth-child(2) div").click()
点击自定义的开关
wd.find_element(By.XPATH,"//em[.=‘ON’]").click()
time.sleep(10)
wd.quit()