Complete the code to import the correct Selenium WebDriver for Chrome.
from selenium import webdriver browser = webdriver.[1]()
The correct WebDriver class to launch Chrome browser is Chrome.
Complete the code to set a Chrome option to disable notifications.
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('[1]') browser = webdriver.Chrome(options=options)
--enable-notifications which enables notifications.--headless.To disable browser notifications in Chrome, use the argument --disable-notifications.
Fix the error in the code to correctly switch to a new browser window.
original_window = browser.current_window_handle browser.find_element('link text', 'Open new window').click() browser.[1](original_window)
switch_to.frame which is for frames, not windows.switch_to.alert which is for alerts.To switch between browser windows, use switch_to.window() method.
Fill both blanks to create a workaround for a Firefox bug by setting a preference and launching Firefox with options.
from selenium.webdriver.firefox.options import Options options = Options() options.set_preference('[1]', False) options.[2] = True browser = webdriver.Firefox(options=options)
disable_notifications.service_log_path with options.To disable web notifications in Firefox, set the preference dom.webnotifications.enabled to False. To run Firefox without opening a window, use headless=True.
Fill all three blanks to create a dictionary comprehension that filters browser logs by level and formats messages.
logs = {entry['timestamp']: entry['message'] for entry in browser.get_log('[1]') if entry['level'] == '[2]' and '[3]' in entry['message']}To get browser logs, use browser as the log type. Filter logs with level SEVERE and messages containing the word error.