Hi,
i'm trying to select multiple options in a dropdown but every time i'm getting the same error saying "ElementNotInteractableException:". i'm copying the code i have used can you please help me where im doing the mistage and how to handle "ElementNotInteractableException:" exceptions
driver.get("https://ej2.syncfusion.com/demos/?_ga=2.74322322.1472942524.1603160175-1138872008.1603160175#/material/multi-select/default.html")
driver.find_element_by_xpath("//*[@id='content']/div[1]/div/div").click()
driver.implicitly_wait(10)
dropdown = Select(driver.find_element_by_xpath("//*[@id='default']"))
print(dropdown.first_selected_option.text)
dropdown.select_by_index("2")
dropdown.select_by_index("4")
time.sleep(15)
driver.quit()
i have tried the same with explicit wait also but still getting the same error.
Thank you,
Instructor
09914040666 Replied on 12/11/2020
Hey
First of all, sorry for delayed solution. Regardig the query, the URL being used here actually is having some background scripts running because of which Select class is not working here on the dropdown. Whatever you try, be it using explicit wait, implicit wait, sleep time, nothing is working here.
Solution to choose the dropdown values can be using ActionChains over here. Below is the working snippet, you may try:
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://ej2.syncfusion.com/demos/?_ga=2.74322322.1472942524.1603160175-1138872008.1603160175#/material/multi-select/default.html")
driver.implicitly_wait(10)
time.sleep(5)
option = driver.find_element_by_xpath("//*[@id='content']/div[1]/div/div")
selectItem = webdriver.ActionChains(driver)
selectItem.move_to_element(option).click(option).perform()
selectItem.send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).perform()
selectItem.send_keys(Keys.ENTER).perform()
time.sleep(5)
driver.quit()