您好,登錄后才能下訂單哦!
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("設(shè)置瀏覽器的寬和高") driver.set_window_size(480,480) sleep(3) print("設(shè)置窗口最大化") driver.maximize_window() sleep(3) driver.quit()
2.控制瀏覽器后退、前進(jìn)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.模擬瀏覽器的刷新
手動(dòng)刷新(F5)頁(yè)面: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()
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。