How to click on the list of the <li> elements in an <ul> elements with selenium in python?
<p><a href="https://i.stack.imgur.com/0rFR0.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/0rFR0.jpg" alt="enter image description here"></a></p>

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

<pre><code>driver.find_element_by_xpath("html/body/main/div/form/div[3]/div[1]/section/div[3]/fieldset/div[7]/dl[1]/dd/ul/li[1]/a").click()
</code></pre>

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

<p>First of all, try to avoid using absolute XPATH.
Use something like this:</p>

<pre><code>'//ul[@id="uiBirthYear"]/li/a[@data-value="2002"]'
</code></pre>

<p>Also ensure, that the DOM is fully built, before you trying to get/click on this element.</p>

<p>Try to set an <em>implicit wait</em></p>

<pre><code>driver.implicitly_wait(10)
</code></pre>

<p>or an <em>explicit wait</em> (read more: <a href="http://selenium-python.readthedocs.io/waits.html" rel="nofollow">http://selenium-python.readthedocs.io/waits.html</a>)</p>

python selenium