from selenium import webdriver
from time import sleep
def maxWin():
chrome = webdriver.Chrome(executable_path = 'C:\Program Files\python\Scripts\chromedriver.exe')
url = 'http://www.baidu.com'
chrome.get(url)
chrome.maximize_window() #最大化窗口
sleep(2)
chrome.quit()
def reSize():
chrome = webdriver.Chrome(executable_path = 'C:\Program Files\python\Scripts\chromedriver.exe')
url = 'http://www.baidu.com'
chrome.get(url)
chrome.set_window_size(300,400) #调节窗口大小
chrome.quit()
def BFWin():
chrome = webdriver.Chrome(executable_path = 'C:\Program Files\python\Scripts\chromedriver.exe')
url = 'http://www.baidu.com'
chrome.get(url)
sleep(2)
chrome.get('http://www.jd.com')
sleep(2)
chrome.back() #后退
sleep(2)
chrome.forward() #前进
sleep(2)
chrome.quit()
if __name__ == '__main__':
#reSize()
BFWin()
Selenium的浏览器操作
最新推荐文章于 2024-07-29 20:35:38 发布