Complete the code to import the class needed for multi-select handling in Selenium.
from selenium.webdriver.support.ui import [1]
The Select class is used to handle multi-select dropdowns in Selenium.
Complete the code to create a Select object for a multi-select element located by id 'fruits'.
select = Select(driver.find_element([1]))To locate an element by id, use By.ID, 'fruits' inside find_element.
Fix the error in the code to select multiple options by visible text.
select.[1]('Apple') select.[1]('Banana')
select_option.select_by_value with select_by_visible_text.The correct method to select options by their visible text is select_by_visible_text.
Fill both blanks to deselect all options and then select by index 2.
select.[1]() select.[2](2)
deselect_by_index instead of deselect_all to clear selections.select_by_value and select_by_index.Use deselect_all() to clear selections, then select_by_index(2) to select the third option.
Fill all three blanks to create a dictionary of selected option texts and their values.
selected_options = {option.[1]: option.[2] for option in select.[3]value property instead of get_attribute('value') which is a method call.options instead of all_selected_options.This code builds a dictionary where keys are option texts and values are their 'value' attributes from all selected options.