TA的每日心情 | 擦汗 8 小时前 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
本帖最后由 测试积点老人 于 2018-4-19 09:43 编辑
问题:
大家好!我用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
复制代码
谢谢大家!
|
|