|
大家好!我用Python Selenium,进行浏览器最小化操作时报异常,源代码:
from selenium import webdriver
from time import sleep
browser = webdriver.Chrome()
browser.get("https://www.baidu.com/")
sleep(1.5)
browser.minimize_window() # 最小化浏览器
browser.quit()
异常信息:
Traceback (most recent call last):
File "F:/Users/lchy/PycharmProjects/Part1_L4.1_BrowserSize/browserSize.py", line 10, in <module>
browser.minimize_window() # 最小化浏览器
File "F:\Users\lchy\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 738, in minimize_window
self.execute(Command.MINIMIZE_WINDOW)
File "F:\Users\lchy\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "F:\Users\lchy\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: unknown command: session/41583399dad2b00396dcbbffa831eadc/window/minimize
虽然觉得最小化没什么意义,但是看到官方API文档中有这个方法,还是想试试,不知该怎么用啊?
API文档中的说明:
Classes
selenium.webdriver.remote.webdriver.WebDriver(builtins.object)
class WebDriver(selenium.webdriver.remote.webdriver.WebDriver)
minimize_window(self)
Invokes the window manager-specific 'minimize' operation
谢谢大家!
|
|