0
0
Selenium Pythontesting~10 mins

Switching between 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 new browser window.

Selenium Python
driver.switch_to.[1](window_handle)
Drag options to blanks, or click blank then click option'
Awindow
Bframe
Calert
Ddefault_content
Attempts:
3 left
💡 Hint
Common Mistakes
Using switch_to.frame instead of switch_to.window
Trying to switch to alert when switching windows
2fill in blank
medium

Complete the code to get all open window handles.

Selenium Python
handles = driver.[1]
Drag options to blanks, or click blank then click option'
Aget_window_handle()
Bcurrent_window_handle
Cwindow_handles
Dswitch_to.window
Attempts:
3 left
💡 Hint
Common Mistakes
Using current_window_handle which returns only one handle
Calling a method instead of accessing a property
3fill in blank
hard

Fix the error in switching back to the original window.

Selenium Python
driver.switch_to.[1](original_handle)
Drag options to blanks, or click blank then click option'
Acurrent_window_handle
Bwindow
Cwindow_handle
Dframe
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning to switch_to.window instead of calling it
Using wrong attribute names
4fill in blank
hard

Fill both blanks to switch to the last opened window.

Selenium Python
driver.switch_to.[1](driver.[2][-1])
Drag options to blanks, or click blank then click option'
Awindow
Bwindow_handles
Ccurrent_window_handle
Dframe
Attempts:
3 left
💡 Hint
Common Mistakes
Using current_window_handle which is a single handle
Trying to switch to a frame instead of a window
5fill in blank
hard

Fill all three blanks to close the current window and switch back to the first window.

Selenium Python
driver.[1]()
driver.switch_to.[2](driver.[3][0])
Drag options to blanks, or click blank then click option'
Aclose
Bwindow
Cwindow_handles
Dquit
Attempts:
3 left
💡 Hint
Common Mistakes
Using quit() which closes all windows
Not switching back after closing the window