coding:utf-8
引用webdriver
from selenium import webdriver
用来查找页面元素的类
from selenium.webdriver.common.by import By
模拟鼠标行为
from selenium.webdriver.common.action_chains import ActionChains
睡眠时间
import time
path = r’D:\webdriver\chromedriver.exe’
打开浏览器
wd = webdriver.Chrome(executable_path=path)
wd.get(‘http://192.168.1.251:9012/ui/test/ex18’)
time.sleep(3)
wd.find_element(By.CSS_SELECTOR,’#newOpen’).click()
time.sleep(3)
#切换到新的标签中 #有多个少标签
wd.switch_to.window(wd.window_handles[1])
wd.find_element(By.CSS_SELECTOR,’#test10’).click()
time.sleep(10)
wd.quit()