0
0
Selenium Pythontesting~10 mins

New window and tab creation 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 open a new browser tab using Selenium.

Selenium Python
driver.[1]
Drag options to blanks, or click blank then click option'
Acreate_tab()
Bopen_new_tab()
Cnew_tab()
Dswitch_to.new_window('tab')
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like open_new_tab() or new_tab()
Trying to call new_window directly on driver without switch_to
2fill in blank
medium

Complete the code to switch Selenium's focus to the newly opened window.

Selenium Python
driver.switch_to.window(driver.[1][-1])
Drag options to blanks, or click blank then click option'
Awindow_handles
Bwindows
Ctabs
Dsessions
Attempts:
3 left
💡 Hint
Common Mistakes
Using driver.windows which does not exist
Using driver.tabs which is not a Selenium property
3fill in blank
hard

Fix the error in the code to open a new window instead of a tab.

Selenium Python
driver.switch_to.[1]('window')
Drag options to blanks, or click blank then click option'
Anew_window
Bcreate_window
Copen_window
Dnew_tab
Attempts:
3 left
💡 Hint
Common Mistakes
Using new_tab instead of new_window to open a window
Trying to call open_window which is not a Selenium method
4fill in blank
hard

Fill both blanks to create a new tab and switch focus to it.

Selenium Python
driver.switch_to.[1]('tab')
driver.switch_to.window(driver.[2][-1])
Drag options to blanks, or click blank then click option'
Anew_window
Bwindow_handles
Cwindows
Dnew_tab
Attempts:
3 left
💡 Hint
Common Mistakes
Using new_tab which is not a valid method
Using windows instead of window_handles to get window handles
5fill in blank
hard

Fill all three blanks to open a new window, switch to it, and verify the title.

Selenium Python
driver.switch_to.[1]('window')
driver.switch_to.window(driver.[2][-1])
assert driver.title [3] ''
Drag options to blanks, or click blank then click option'
Anew_window
Bwindow_handles
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of == in the assertion
Using new_tab instead of new_window to open a window