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(3)
#如果页面3秒钟都还没有加载完成的话
#那么我们继续尝试去做其它控件的操作
try:
wd.get(‘http://192.168.1.251:9012/ui/test/ex13’)
except Exception as e:
print(e)
finally:
#获取页面的标题
print(‘页面的标题{}’.format(wd.title))
print(’-----------------------------’)
print(‘获取页面的源代码\n{}’.format(wd.page_source))
time.sleep(1)
wd.find_element_by_name(‘start’).click()
time.sleep(3)
wd.quit()