Hint: get_window_size() returns dict with width and height [OK]
Common Mistakes:
Expecting get_window_size() to return None or error
Thinking maximize_window() does not affect size
Confusing method names
4. Identify the error in the following Selenium Python code that tries to minimize the browser window:
from selenium import webdriver
driver = webdriver.Firefox()
driver.minimize()
medium
A. The method minimize() does not exist; should use minimize_window()
B. Firefox driver does not support window operations
C. Missing parentheses after webdriver.Firefox
D. minimize() should be called before creating the driver
Solution
Step 1: Check method name correctness
The method to minimize the window is minimize_window(), not minimize().
Step 2: Verify driver and method compatibility
Firefox driver supports window operations, so the error is due to wrong method name.
Final Answer:
The method minimize() does not exist; should use minimize_window() -> Option A
Quick Check:
Correct method = minimize_window() [OK]
Hint: Use full method names exactly as in docs [OK]
Common Mistakes:
Using minimize() instead of minimize_window()
Assuming Firefox driver lacks window methods
Forgetting parentheses on driver creation
5. You want to test how your website behaves when the browser window is minimized and then maximized again. Which sequence of Selenium Python commands correctly achieves this?
hard
A. driver.minimize_window()
driver.maximize_window()
B. driver.maximize_window()
driver.minimize_window()
C. driver.set_window_size(0, 0)
driver.maximize_window()
D. driver.minimize()
driver.maximize()
Solution
Step 1: Minimize the window first
Use minimize_window() to hide the browser window.
Step 2: Maximize the window after minimizing
Use maximize_window() to restore it to full screen.
Step 3: Verify method correctness
Options A, C, and D use incorrect methods or order; A reverses the intended test flow.
Final Answer:
driver.minimize_window()
driver.maximize_window() -> Option A
Quick Check:
Minimize then maximize = B [OK]
Hint: Minimize first, then maximize to test window state changes [OK]
Common Mistakes:
Reversing the order of minimize and maximize
Using incorrect method names like minimize()
Trying to set size to zero instead of minimizing
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.