0
0
Selenium Pythontesting~20 mins

Window size control in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Window Size Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the window size after resizing?
Given the following Selenium Python code snippet, what will be the window size after execution?
Selenium Python
from selenium import webdriver

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
driver.set_window_size(800, 600)
size = driver.get_window_size()
print(size)
driver.quit()
A{'width': 800, 'height': 600}
B{'width': 1024, 'height': 768}
C{'width': 0, 'height': 0}
DRaises an exception
Attempts:
2 left
💡 Hint
The set_window_size method sets the browser window to the specified width and height.
assertion
intermediate
2:00remaining
Which assertion correctly verifies window size?
You want to assert that the browser window width is exactly 1024 pixels after resizing. Which assertion is correct?
Selenium Python
driver.set_window_size(1024, 768)
size = driver.get_window_size()
Aassert size.width == 1024
Bassert size['width'] == 1024
Cassert size.get('height') == 1024
Dassert size['width'] > 1024
Attempts:
2 left
💡 Hint
get_window_size returns a dictionary with keys 'width' and 'height'.
🔧 Debug
advanced
2:00remaining
Why does this window resize code fail?
This Selenium Python code throws an error. What is the cause?
Selenium Python
driver = webdriver.Chrome()
driver.set_window_size(800)
size = driver.get_window_size()
Awebdriver.Chrome() must be called with options argument
Bdriver.get_window_size() is deprecated and causes error
Cset_window_size requires two arguments: width and height
Dset_window_size only accepts string arguments
Attempts:
2 left
💡 Hint
Check the method signature for set_window_size.
🧠 Conceptual
advanced
2:00remaining
What happens if you maximize window before setting size?
In Selenium Python, if you call driver.maximize_window() before driver.set_window_size(800, 600), what will be the final window size?
AThe window size will be 800x600 as set by set_window_size
BThe window size will be the default browser size
CThe window remains maximized ignoring set_window_size
DAn error is raised because maximize_window conflicts with set_window_size
Attempts:
2 left
💡 Hint
Later commands override earlier ones.
framework
expert
3:00remaining
How to reliably test window resizing in Selenium tests?
You want to write a Selenium test that verifies your web app layout changes correctly when the window is resized. Which approach is best?
AUse driver.get_window_size() only without resizing
BUse driver.maximize_window() and assume layout adapts automatically
CManually resize the browser window during test execution
DUse driver.set_window_size() to resize, then assert layout changes using element properties
Attempts:
2 left
💡 Hint
Automate resizing and verify layout programmatically.