Selenium操作浏览器
import time
from selenium import webdriver
#打开浏览器
driver=webdriver.Chrome();
#在浏览器中打开被测项目地址
driver.get("http://www.baidu.com")
#窗口最大化
time.sleep(3)
driver.maximize_window()
#窗口最小化
time.sleep(3)
driver.minimize_window()
#设置打开窗口大小
time.sleep(3)
driver.set_window_size(800,800)
#回退
time.sleep(3)
driver.back()
#前进
time.sleep(3)
driver.forward()
#刷新
time.sleep(3)
driver.refresh()
#获得标题
time.sleep(3)
print(driver.title)
#获得当前路径
time.sleep(3)
print(driver.current_url)
#获得页面代码
time.sleep(3)
print(driver.page_source)
#截图
time.sleep(3)
driver.get_screenshot_as_file("E:\a.png")
#关闭浏览器
time.sleep(3)
driver.close()
#退出当前driver
driver.quit()