0
0
Selenium Pythontesting~5 mins

Handling pop-up windows in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a pop-up window in web testing?
A pop-up window is a small browser window that appears on top of the main window, often used for alerts, confirmations, or additional information.
Click to reveal answer
beginner
How do you switch control to a pop-up window in Selenium with Python?
Use driver.switch_to.window(window_handle) where window_handle is the identifier of the pop-up window.
Click to reveal answer
beginner
What method is used to accept an alert pop-up in Selenium Python?
Use driver.switch_to.alert.accept() to click the OK button on an alert pop-up.
Click to reveal answer
intermediate
Why is it important to switch back to the main window after handling a pop-up?
Because Selenium stays focused on the pop-up window, switching back ensures further commands affect the main page, avoiding errors.
Click to reveal answer
beginner
How can you get all open window handles in Selenium Python?
Use driver.window_handles which returns a list of all window identifiers currently open.
Click to reveal answer
Which Selenium method switches control to a pop-up alert?
Adriver.switch_to.frame
Bdriver.switch_to.window
Cdriver.get_alert()
Ddriver.switch_to.alert
What does driver.window_handles return?
AList of all alert messages
BCurrent window handle
CList of all open window handles
DNumber of pop-ups
After closing a pop-up window, what should you do next?
AClose the browser
BSwitch back to the main window
CRefresh the page
DDo nothing
Which method accepts a confirmation pop-up in Selenium Python?
Adriver.switch_to.alert.accept()
Bdriver.switch_to.alert.dismiss()
Cdriver.close()
Ddriver.quit()
How do you get the current window handle in Selenium Python?
Adriver.current_window_handle
Bdriver.window_handles[0]
Cdriver.get_window()
Ddriver.switch_to.window()
Explain the steps to handle a pop-up alert window in Selenium Python.
Think about how Selenium changes focus to pop-ups.
You got /3 concepts.
    Describe how to switch between multiple browser windows in Selenium Python.
    Remember window handles are like window IDs.
    You got /4 concepts.