Challenge - 5 Problems
Full Page Screenshot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium Python code snippet?
Consider the following code that attempts to take a full page screenshot using Selenium in Python. What will be the result of running this code?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless=new') service = Service() driver = webdriver.Chrome(service=service, options=options) driver.get('https://example.com') # Attempt to take full page screenshot result = driver.save_screenshot('page.png') driver.quit() print(result)
Attempts:
2 left
💡 Hint
The save_screenshot method captures only the visible part of the page by default.
✗ Incorrect
The save_screenshot method returns True if the screenshot is saved successfully. However, it captures only the visible viewport, not the full page. To capture the full page, additional steps or tools are needed.
🧠 Conceptual
intermediate2:00remaining
Which Selenium Python approach captures a full page screenshot?
You want to capture a full page screenshot of a webpage using Selenium with Python. Which approach below will correctly capture the entire page, not just the visible viewport?
Attempts:
2 left
💡 Hint
Think about how to make the browser window tall enough to show the entire page.
✗ Incorrect
To capture the full page, you can use JavaScript to get the full page height, resize the browser window to that height, then take a screenshot. This ensures the entire page is visible in the viewport.
🔧 Debug
advanced2:00remaining
Why does this full page screenshot code fail with an error?
This Selenium Python code tries to take a full page screenshot but raises an error. What is the cause?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service service = Service() driver = webdriver.Chrome(service=service) driver.get('https://example.com') height = driver.execute_script('return document.body.scrollHeight') driver.set_window_size(1200, height) screenshot = driver.get_screenshot_as_file('fullpage.png') driver.quit()
Attempts:
2 left
💡 Hint
Browsers limit window size; very tall sizes cause errors.
✗ Incorrect
Browsers have maximum window size limits. Setting window height to the full page height can exceed this limit and cause errors. You need to handle this by scrolling and stitching screenshots or using browser-specific full page screenshot features.
❓ framework
advanced2:00remaining
Which Selenium WebDriver method supports full page screenshots in recent versions?
Recent Selenium WebDriver versions introduced a method to capture full page screenshots directly. Which method is it?
Attempts:
2 left
💡 Hint
Look for a method returning a base64 string with 'full_page' in its name.
✗ Incorrect
Selenium 4.8+ added get_full_page_screenshot_as_base64() to capture full page screenshots as base64 strings. This method captures the entire page, unlike get_screenshot_as_file which captures only the viewport.
❓ assertion
expert2:00remaining
Which assertion correctly verifies a full page screenshot file exists and is not empty?
After taking a full page screenshot saved as 'fullpage.png', which assertion best confirms the file exists and has content?
Attempts:
2 left
💡 Hint
File must exist and have size greater than zero.
✗ Incorrect
To verify a screenshot file is created and not empty, check that the file exists and its size is greater than zero bytes.