Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:
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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading