python how to check if selenium webdriver is minimized

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

Read more here: Source link