python how to check if selenium webdriver is minimized

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:
but it will return browser size before minimized, and also i have read this question but there is no


attribute, you can help me please

>Solution :

I’ve experimented with get_window_position(). And here is what I’ve got:

driver = webdriver.Chrome()
print('default:', driver.get_window_position())
print('maximized:', driver.get_window_position())
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

Leave a Reply