Recall & Review
beginner
What Selenium method is used to open a new browser tab or window?
The
driver.switch_to.new_window() method is used to open a new tab or window in Selenium with Python.Click to reveal answer
beginner
How do you switch control to a newly opened tab or window in Selenium?
Use
driver.switch_to.window(window_handle) where window_handle is the unique ID of the new tab or window.Click to reveal answer
intermediate
What is the difference between opening a new tab and a new window in Selenium?
Using
driver.switch_to.new_window('tab') opens a new tab, while driver.switch_to.new_window('window') opens a new browser window.Click to reveal answer
beginner
Why is it important to keep track of window handles when working with multiple tabs/windows?
Window handles let you identify and switch between different tabs or windows. Without them, Selenium cannot control the right browser context.Click to reveal answer
intermediate
How can you close a specific tab or window in Selenium?
Switch to the tab/window using its handle, then call
driver.close() to close it. Use driver.switch_to.window() before closing.Click to reveal answer
Which Selenium method opens a new browser tab?
✗ Incorrect
The correct method is
driver.switch_to.new_window('tab') to open a new tab.How do you switch control to a new window in Selenium?
✗ Incorrect
Use
driver.switch_to.window(window_handle) to switch control to an existing window.What does
driver.close() do in Selenium?✗ Incorrect
driver.close() closes only the current tab or window Selenium is controlling.Why do you need window handles in Selenium?
✗ Incorrect
Window handles uniquely identify each tab or window so Selenium can switch control.
Which argument opens a new browser window instead of a tab?
✗ Incorrect
Use
driver.switch_to.new_window('window') to open a new browser window.Explain how to open a new tab, switch to it, and then close it using Selenium with Python.
Think about the sequence: open, switch, close.
You got /3 concepts.
Describe why managing window handles is important when working with multiple browser tabs or windows in Selenium.
Consider how Selenium knows which tab or window to work with.
You got /3 concepts.