0
0
Selenium Pythontesting~10 mins

Multi-select handling 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 class needed for multi-select handling in Selenium.

Selenium Python
from selenium.webdriver.support.ui import [1]
Drag options to blanks, or click blank then click option'
AWebDriverWait
BSelect
CActionChains
DBy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong class like WebDriverWait or ActionChains.
Forgetting to import the Select class.
2fill in blank
medium

Complete the code to create a Select object for a multi-select element located by id 'fruits'.

Selenium Python
select = Select(driver.find_element([1]))
Drag options to blanks, or click blank then click option'
A(By.NAME, 'fruits')
B'fruits'
C(By.CLASS_NAME, 'fruits')
D(By.ID, 'fruits')
Attempts:
3 left
💡 Hint
Common Mistakes
Passing only the string 'fruits' instead of a locator tuple.
Using the wrong locator type like By.NAME or By.CLASS_NAME.
3fill in blank
hard

Fix the error in the code to select multiple options by visible text.

Selenium Python
select.[1]('Apple')
select.[1]('Banana')
Drag options to blanks, or click blank then click option'
Aselect_by_visible_text
Bselect_option
Cselect_by_index
Dselect_by_value
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like select_option.
Confusing select_by_value with select_by_visible_text.
4fill in blank
hard

Fill both blanks to deselect all options and then select by index 2.

Selenium Python
select.[1]()
select.[2](2)
Drag options to blanks, or click blank then click option'
Adeselect_all
Bselect_by_value
Cselect_by_index
Ddeselect_by_index
Attempts:
3 left
💡 Hint
Common Mistakes
Using deselect_by_index instead of deselect_all to clear selections.
Mixing up select_by_value and select_by_index.
5fill in blank
hard

Fill all three blanks to create a dictionary of selected option texts and their values.

Selenium Python
selected_options = {option.[1]: option.[2] for option in select.[3]
Drag options to blanks, or click blank then click option'
Atext
Bget_attribute('value')
Call_selected_options
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using value property instead of get_attribute('value') which is a method call.
Using options instead of all_selected_options.