Test Overview
This test opens a browser, maximizes the window, verifies the window is maximized, then minimizes the window and verifies it is minimized.
This test opens a browser, maximizes the window, verifies the window is maximized, then minimizes the window and verifies it is minimized.
from selenium import webdriver from selenium.webdriver.chrome.service import Service import time # Setup WebDriver service = Service() driver = webdriver.Chrome(service=service) try: # Open a website driver.get('https://example.com') # Maximize the window driver.maximize_window() time.sleep(1) # wait for window to maximize # Verify window is maximized by checking window size is greater than a threshold size_max = driver.get_window_size() assert size_max['width'] > 800 and size_max['height'] > 600, 'Window not maximized properly' # Minimize the window driver.minimize_window() time.sleep(1) # wait for window to minimize # Verify window is minimized by checking window is not visible or size is small # Selenium does not provide direct visibility, so we check size is small or zero size_min = driver.get_window_size() assert size_min['width'] < 300 and size_min['height'] < 300, 'Window not minimized properly' finally: driver.quit()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and WebDriver Chrome instance is created | Browser window is opened but not navigated | - | PASS |
| 2 | Browser navigates to https://example.com | Browser displays example.com homepage | - | PASS |
| 3 | Browser window is maximized using driver.maximize_window() | Browser window is maximized to full screen | Check window width > 800 and height > 600 | PASS |
| 4 | Browser window is minimized using driver.minimize_window() | Browser window is minimized (small or hidden) | Check window width < 300 and height < 300 | PASS |
| 5 | Browser is closed with driver.quit() | Browser window closed, WebDriver session ended | - | PASS |