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.

Quiz on Selenium

Q1. What is a web driver in Selenium Python?

Not answered

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

Not answered

Q3. What is the method used to navigate back to the previous page in Selenium Python?

Not answered

Q4. What is the method used to select a value from a drop-down list 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 👍