MCQs on Handling Multi-Select Dropdowns Using Selenium Java
Which class in Selenium is used to handle multi-select dropdowns?
a) WebElement
b) MultiSelect
c) Select
d) Dropdown
Answer: c) Select
How do you verify if a dropdown allows multiple selections?
a) dropdown.isMultiple()
b) dropdown.isMultiSelect()
c) dropdown.isMultipleSelect()
d) dropdown.isSelectable()
Answer: a) dropdown.isMultiple()
Which method is used to select multiple options in a dropdown by their visible text?
a) selectByText()
b) selectByVisibleText()
c) selectMultipleByText()
d) selectByValue()
Answer: b) selectByVisibleText()
How can you select multiple options in a dropdown by their values using Selenium?
a) selectByMultipleValues()
b) selectByValue("value1"); selectByValue("value2");
c) selectByIndex(1, 2)
d) selectMultipleOptions()
Answer: b) selectByValue("value1"); selectByValue("value2");
Which method would you use to deselect all selected options in a multi-select dropdown?
a) clearAllSelections()
b) deselectAll()
c) removeAllSelections()
d) clearSelections()
Answer: b) deselectAll()
What is the method to deselect an option in a multi-select dropdown by its index?
a) deselectByIndex()
b) removeByIndex()
c) deselectOptionByIndex()
d) clearByIndex()
Answer: a) deselectByIndex()
Which method is used to deselect an option by its visible text in a multi-select dropdown?
a) deselectByValue()
b) deselectByText()
c) deselectByVisibleText()
d) clearByVisibleText()
Answer: c) deselectByVisibleText()
How do you retrieve all selected options from a multi-select dropdown?
a) getAllSelectedOptions()
b) getSelectedOptions()
c) getAllOptions()
d) getFirstSelectedOption()
Answer: a) getAllSelectedOptions()
Which method will throw an exception if the multi-select dropdown does not have the specified option?
a) selectByIndex()
b) selectByValue()
c) selectByVisibleText()
d) All of the above
Answer: d) All of the above
What exception is thrown when trying to deselect an option from a single-select dropdown?
a) InvalidOperationException
b) UnsupportedOperationException
c) NotImplementedException
d) NoSuchElementException
Answer: b) UnsupportedOperationException
To select multiple options using Selenium in a multi-select dropdown, which looping structure is commonly used?
a) for loop
b) while loop
c) do-while loop
d) for-each loop
Answer: d) for-each loop
Which Selenium method checks if an option in a multi-select dropdown is selected?
a) isOptionSelected()
b) isSelected()
c) isMultiSelected()
d) isMultiple()
Answer: b) isSelected()
How would you deselect an option in a multi-select dropdown by its value?
a) deselectByText()
b) deselectByValue()
c) deselectByOptionValue()
d) removeByValue()
Answer: b) deselectByValue()
Which method retrieves the first selected option from a multi-select dropdown?
a) getFirstSelectedOption()
b) getSelectedOption()
c) getAllSelectedOptions()
d) getFirstOption()
Answer: a) getFirstSelectedOption()
How do you check if a dropdown element is a multi-select dropdown before performing operations?
a) if (dropdown.isMulti())
b) if (dropdown.isMultiple())
c) if (dropdown.isMultiSelect())
d) if (dropdown.isEnabled())
Answer: b) if (dropdown.isMultiple())
In a multi-select dropdown, what is the default behavior of deselectAll()?
a) Deselects all selected options
b) Throws an exception if there are no selected options
c) Selects all options
d) Does nothing
Answer: a) Deselects all selected options
Which method in the Select class is not applicable to single-select dropdowns?
a) selectByVisibleText()
b) selectByValue()
c) deselectAll()
d) selectByIndex()
Answer: c) deselectAll()
What is the return type of getAllSelectedOptions() in Selenium?
a) List<WebElement>
b) WebElement
c) ArrayList<WebElement>
d) Set<WebElement>
Answer: a) List<WebElement>
When using isMultiple() in Selenium, what does it check?
a) If multiple dropdowns exist on the page
b) If the dropdown allows multiple selections
c) If more than one option is selected
d) If the dropdown is visible
Answer: b) If the dropdown allows multiple selections
No comments:
Post a Comment