Selenium – Minimize Window

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()
Copy

When 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.

Related Tutorials

Quiz on Selenium

Q1. What is the method used to interact with web elements in Selenium Python?

Not answered

Q2. Which of the following is not a method to wait for a web element to load in Selenium Python?

Not answered

Q3. Which of the following is not a commonly used assertion method in Selenium Python?

Not answered

Q4. What is the method used to take a screenshot in Selenium Python?

Not answered

Q5. What is the method used to clear the text from an input field in Selenium Python?

Not answered
Code copied to clipboard successfully 👍