您好,登錄后才能下訂單哦!
1控制瀏覽器窗口的大小
driver.set_window_size(480,480) 代碼:
from selenium import webdriver from time import * driver = webdriver.Chrome() url = "http://www.baidu.com" driver.get(url) print("設置瀏覽器的寬和高") driver.set_window_size(480,480) sleep(3) print("設置窗口最大化") driver.maximize_window() sleep(3) driver.quit()
2.控制瀏覽器后退、前進back和forward方法
from selenium import webdriver from time import * driver = webdriver.Chrome() url = "http://www.baidu.com" print('new access %s' %(url)) driver.get(url) url2 = 'http://news.baidui.com' print('new access %s' %(url2)) driver.get(url2) sleep(3) print("back to %s" %(url)) driver.back() sleep(3) print("forword to %s" %(url2)) driver.forward() sleep(3) driver.quit()
3.模擬瀏覽器的刷新
手動刷新(F5)頁面:driver.refresh()
from selenium import webdriver
from time import *
driver = webdriver.Chrome()
url = "http://www.baidu.com"
print('new access %s' %(url))
driver.get(url)
sleep(3)
driver.refresh()
sleep(3)
driver.quit()
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。