0
0
Selenium Pythontesting~20 mins

Full page screenshot in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Full Page Screenshot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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)
AFalse (screenshot not saved due to missing permissions)
BTrue (screenshot saved as 'page.png', but only visible viewport captured)
CThrows an exception because save_screenshot does not exist
DTrue (full page screenshot saved as 'page.png')
Attempts:
2 left
💡 Hint
The save_screenshot method captures only the visible part of the page by default.
🧠 Conceptual
intermediate
2: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?
AUse JavaScript to get page height, resize window, then save_screenshot
BUse driver.execute_script('window.scrollTo(0,0)') then save_screenshot
CUse driver.get_screenshot_as_base64() only
DUse driver.save_screenshot('file.png') directly
Attempts:
2 left
💡 Hint
Think about how to make the browser window tall enough to show the entire page.
🔧 Debug
advanced
2: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()
Aexecute_script returns None causing set_window_size to fail
Bset_window_size is not a valid method on driver
Cget_screenshot_as_file requires a full file path, not just filename
DThe window height exceeds maximum allowed size causing error
Attempts:
2 left
💡 Hint
Browsers limit window size; very tall sizes cause errors.
framework
advanced
2: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?
Adriver.get_full_page_screenshot_as_file('file.png')
Bdriver.full_page_screenshot()
Cdriver.get_full_page_screenshot_as_base64()
Ddriver.get_screenshot_as_file('file.png')
Attempts:
2 left
💡 Hint
Look for a method returning a base64 string with 'full_page' in its name.
assertion
expert
2: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?
Aassert os.path.exists('fullpage.png') and os.path.getsize('fullpage.png') > 0
Bassert os.path.isfile('fullpage.png') == False
Cassert os.path.getsize('fullpage.png') == 0
Dassert os.path.exists('fullpage.png') and os.path.getsize('fullpage.png') == 0
Attempts:
2 left
💡 Hint
File must exist and have size greater than zero.