Home > database >  Python Selenium, Dropdown Option Element is not currently visible and may not be manipulated
Python Selenium, Dropdown Option Element is not currently visible and may not be manipulated

Time:03-24

I'm getting this error

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: Element is not currently visible and may not be manipulated

For this line with //option[. = 'Individual']

dropdown = self.driver.find_element(By.CSS_SELECTOR, "#selectClaimantTypeContainer select")
WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//option[. = 'Individual']"))).click()

I've added WebDriverWait and still the error persists? The dropdown options are loaded dynamically via ajax.

How do i solve? This is how the code looks with WebDriverWait

dropdown = self.driver.find_element(By.CSS_SELECTOR, "#selectClaimantTypeContainer select")
dropdown.find_element(By.XPATH, "//option[. = 'Individual']").click()

CodePudding user response:

Looks like it's a Select element there. So you need to select the desired option by value or by visible text, as following:

dropdown = self.driver.find_element(By.CSS_SELECTOR, "#selectClaimantTypeContainer select")
dropdown.select_by_visible_text('Individual')

  • Related