Message: Element could not be scrolled into view while trying to click on an option within a dropdown menu through Selenium

This error message…

selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view.

…implies that the <option> item which your program was trying to interact with could not be scrolled into view.

The HTML of the desired element would have given us some idea behind the error. However it seems the desired element was not clickable / within the Viewport. To address the issue you have to induce WebDriverWait for the element to be clickable and you can use the following solution:

mySelectElement = browser.find_element_by_id('providerTypeDropDown')
dropDownMenu = Select(mySelectElement)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='providerTypeDropDown']//options[contains(.,'Professional')]")))
dropDownMenu.select_by_visible_text('Professional')

Note : You have to add the following imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select

Leave a Comment