I've read through several minimization-related questions using Selenium but nowhere in their documentation says how to interface with a window that has been minimized. If you try running the set_window_size()
or maximize_window()
functions on the driver after minimizing the browser, Selenium throws an exception stating that the window state is invalid for these operations. I find it hard to believe that once you minimize the window you can no longer drive the browser. Has anyone done this?
EDIT: Here's my code:
self.driver.minimize_window()
self.driver.maximize_window()
And here's the traceback I'm seeing:
Traceback (most recent call last):
...
self.browser.maximize_window()
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 737, in maximize_window
self.execute(command, params)
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: failed to change window state to normal, current state is minimized
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.41,platform=Linux 4.15.0-39-generic x86_64)