everline everline - 10 days ago 4
Python Question

How to click on the list of the <li> elements in an <ul> elements with selenium in python?

enter image description here

I tried to select 2002 in dropdown menu.
It doesn't work at any late.
I used xpath


but it doesn't work..I tried all the solutions I got...
How can I select this?


If you're able to open dropdown item but unable to click on item, you should try using Explicit Waits with WebDriverWait to wait until this element is visible and enable to click as below :-

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

element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "ul#ulBirthYear a[data-value='2002']")))


element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "2002")))