Test Overview
This test opens a webpage and captures a full page screenshot. It verifies that the screenshot file is created successfully.
This test opens a webpage and captures a full page screenshot. It verifies that the screenshot file is created successfully.
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options import os import time def test_full_page_screenshot(): options = Options() options.add_argument('--headless=new') service = Service() driver = webdriver.Chrome(service=service, options=options) try: driver.get('https://example.com') time.sleep(2) # Wait for page to load fully screenshot_path = 'full_page_screenshot.png' # Selenium 4.1+ supports full page screenshot for Chrome driver.get_full_page_screenshot_as_file(screenshot_path) assert os.path.exists(screenshot_path), 'Screenshot file was not created.' finally: driver.quit()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test environment initialized, ChromeDriver ready | - | PASS |
| 2 | Browser opens Chrome in headless mode | Chrome browser instance running without UI | - | PASS |
| 3 | Navigates to 'https://example.com' | Example.com homepage loaded fully | - | PASS |
| 4 | Waits 2 seconds for full page load | Page content fully rendered | - | PASS |
| 5 | Captures full page screenshot and saves as 'full_page_screenshot.png' | Screenshot file created in test folder | Check if 'full_page_screenshot.png' file exists | PASS |
| 6 | Closes browser and ends test | Browser closed, resources freed | - | PASS |