the problem is i don't know how to check if browser has minimized, so how to check if browser is minimized on selenium (python)? i have tried this code:
driver.get_window_size()
but it will return browser size before minimized, and also i have read this question but there is no
driver.manage()
attribute, you can help me please
CodePudding user response:
I've experimented with get_window_position()
. And here is what I've got:
driver = webdriver.Chrome()
print('default:', driver.get_window_position())
driver.maximize_window()
print('maximized:', driver.get_window_position())
driver.minimize_window()
print('minimized:', driver.get_window_position())
with the result:
default: {'x': 10, 'y': 42}
maximized: {'x': 0, 'y': 32}
minimized: {'x': 32, 'y': 61}
So the maximized window always has x = 0
. I guess other coordinates depend on the screen size. So, for my screen the minimized window will have x = 32
or i can just check that it's higher than 10:
is_minimized = driver.get_window_position()['x'] > 10
print(is_minimized) # True