如何用 Python 在 Selenium 中最大化和最小化瀏覽器?
在 Selenium 中測試應用時,我們可以最大化和最小化瀏覽器。
若要最大化瀏覽器,需使用 maximize() 方法。
若要最小化瀏覽器,需使用 minimize() 方法。
這兩個方法可在同一程式中同時使用。
示例
程式碼實現
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Firefox(executable_path="C:\geckodriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://tutorialspoint.tw/index.htm")
#to refresh the browser
driver.refresh()
# to minimize the browser window
driver.minimize_window()
#to close the browser
driver.close()
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP