0
0
Selenium Pythontesting~10 mins

Handling pop-up windows in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to switch to the pop-up alert window.

Selenium Python
alert = driver.switch_to.[1]()
Drag options to blanks, or click blank then click option'
Adefault_content
Bwindow
Cframe
Dalert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'window' or 'frame' instead of 'alert' causes errors.
Forgetting that 'alert' is a property, not a method (no parentheses).
2fill in blank
medium

Complete the code to accept (click OK) on the alert pop-up.

Selenium Python
alert.[1]()
Drag options to blanks, or click blank then click option'
Adismiss
Bsend_keys
Caccept
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dismiss' cancels the alert instead of accepting.
Trying to use 'send_keys' on alerts that don't accept input.
3fill in blank
hard

Fix the error in switching back to the main window after handling a pop-up.

Selenium Python
driver.switch_to.[1]()
Drag options to blanks, or click blank then click option'
Aalert
Bdefault_content
Cwindow
Dparent_frame
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alert' again keeps focus on the pop-up.
Using 'window' is not a valid method here.
4fill in blank
hard

Fill both blanks to switch to a new browser window and then close it.

Selenium Python
driver.switch_to.[1](driver.window_handles[1])
driver.[2]()
Drag options to blanks, or click blank then click option'
Awindow
Bclose
Calert
Dquit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alert' instead of 'window' for switching windows.
Using 'quit' closes the whole browser, not just one window.
5fill in blank
hard

Fill all three blanks to handle a prompt pop-up by sending text, accepting it, and switching back to main window.

Selenium Python
alert = driver.switch_to.[1]()
alert.[2]('Hello')
alert.[3]()
Drag options to blanks, or click blank then click option'
Aalert
Bsend_keys
Caccept
Ddismiss
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to send keys before switching to alert.
Using 'dismiss' instead of 'accept' cancels the prompt.