如何用 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.com/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