Test Overview
This test opens a browser, sets the window size to 1024x768 pixels, and verifies that the window size is correctly applied.
This test opens a browser, sets the window size to 1024x768 pixels, and verifies that the window size is correctly applied.
from selenium import webdriver from selenium.webdriver.chrome.service import Service import time # Initialize Chrome WebDriver service = Service() driver = webdriver.Chrome(service=service) try: # Open a website driver.get('https://example.com') # Set window size to 1024x768 driver.set_window_size(1024, 768) # Get current window size size = driver.get_window_size() # Assert window size is as expected assert size['width'] == 1024 and size['height'] == 768, f"Window size is {size}, expected 1024x768" finally: driver.quit()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Initialize Chrome WebDriver | Browser is starting but not yet opened any page | - | PASS |
| 2 | Open the URL 'https://example.com' | Browser displays the Example Domain homepage | - | PASS |
| 3 | Set browser window size to width=1024 and height=768 | Browser window is resized to 1024x768 pixels | - | PASS |
| 4 | Retrieve current window size | Browser window size info is fetched | Check if width == 1024 and height == 768 | PASS |
| 5 | Assert that window size matches 1024x768 | Window size is confirmed as 1024x768 | Assertion passes if size matches expected values | PASS |
| 6 | Close the browser | Browser is closed and WebDriver session ends | - | PASS |