Dropdown Element with option text values in ul list - Element is not currently visible and may not be manipulated

Viewed 30

enter image description here

enter image description here

I want to select the option with the value "DATE" using Selenium. The thing about it is that the option text is set in another part which is the ul list. I tried some of the solutions that I found but none of them worked. Here's my code:

        WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.XPATH, '//select[@data-test="FilterSorts"]')))
        dropdown_trigger = browser.find_element_by_xpath('//select[@data-test="FilterSorts"]')
        browser.execute_script("arguments[0].click();", dropdown_trigger)
        dropdown_option = WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.XPATH, "//option[@value='DATE']")))
        dropdown_option.click()

I also tried this and still got the same error:

WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.XPATH, '//select[@data-test="FilterSorts"]')))
dropdown_trigger = browser.find_element_by_xpath('//select[@data-test="FilterSorts"]')
select = Select(dropdown_trigger)
select.select_by_value('DATE').click()

error:

dropdown_trigger = browser.find_element_by_xpath('//select[@data-test="FilterSorts"]') Message: element not interactable: Element is not currently visible and may not be manipulated

1 Answers

Here's the solution that worked for me:

#Identify the element
element = browser.find_element_by_xpath("//span[contains(text(),'Most Recent')]") 
#Apply Javascript of click action
browser.execute_script("arguments[0].click();", element)
Related