Contents
Selenium – Minimize window
In this tutorial, you will learn how to minimize browser window using Selenium in Python, with examples.
To minimize the browser window using webdriver object in Selenium, call minimize_window() function on the webdriver object.
driver.minimize_window()
Examples
1. Minimize Chrome browser window
In the following program, we initialize a webdriver that opens the browser window, and then minimize the window using minimize_window() method..
Python Program
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
# Setup chrome driver
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Minimize the browser window
driver.minimize_window()
CopyWhen you run this program, a browser window is created, and upon the execution of minimize_window() method, the browser window would be minimized, and would have gone to the Taskbar or Dock.
Whatever the browser you would like to test on, the process is same. Just call the minimize_window() method on that webdriver object.
Summary
In this Python Selenium tutorial, we have seen how to minimize a browser window using Selenium webdriver, with example programs.