0
0
Selenium Pythontesting~10 mins

Browser-specific workarounds 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 import the correct Selenium WebDriver for Chrome.

Selenium Python
from selenium import webdriver

browser = webdriver.[1]()
Drag options to blanks, or click blank then click option'
AEdge
BFirefox
CSafari
DChrome
Attempts:
3 left
💡 Hint
Common Mistakes
Using Firefox or Safari WebDriver when Chrome is needed.
Misspelling the WebDriver class name.
2fill in blank
medium

Complete the code to set a Chrome option to disable notifications.

Selenium Python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('[1]')
browser = webdriver.Chrome(options=options)
Drag options to blanks, or click blank then click option'
A--disable-notifications
B--enable-notifications
C--start-maximized
D--headless
Attempts:
3 left
💡 Hint
Common Mistakes
Using --enable-notifications which enables notifications.
Using unrelated options like --headless.
3fill in blank
hard

Fix the error in the code to correctly switch to a new browser window.

Selenium Python
original_window = browser.current_window_handle
browser.find_element('link text', 'Open new window').click()
browser.[1](original_window)
Drag options to blanks, or click blank then click option'
Aswitch_to.frame
Bswitch_to.window
Cswitch_to.alert
Dswitch_to.default_content
Attempts:
3 left
💡 Hint
Common Mistakes
Using switch_to.frame which is for frames, not windows.
Using switch_to.alert which is for alerts.
4fill in blank
hard

Fill both blanks to create a workaround for a Firefox bug by setting a preference and launching Firefox with options.

Selenium Python
from selenium.webdriver.firefox.options import Options
options = Options()
options.set_preference('[1]', False)
options.[2] = True
browser = webdriver.Firefox(options=options)
Drag options to blanks, or click blank then click option'
Adom.webnotifications.enabled
Bheadless
Cservice_log_path
Ddisable_notifications
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect preference names like disable_notifications.
Confusing service_log_path with options.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters browser logs by level and formats messages.

Selenium Python
logs = {entry['timestamp']: entry['message'] for entry in browser.get_log('[1]') if entry['level'] == '[2]' and '[3]' in entry['message']}
Drag options to blanks, or click blank then click option'
Abrowser
BSEVERE
Cerror
Dperformance
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'performance' instead of 'browser' for log type.
Filtering by wrong log level or message content.