I'm using Python Selenium to locate element by using nth-child(n).
Below is my html code:
<div id="iopop" style="">
<div style="" class="">
<div id="iopoph" class="animated zoomIn" style=" ">
<span style="" class="gs_hover"></span>
<b class="in">FALAFEL</b>
<a iid="128-73" class="itemsub lowend" price="2.99" name="FALAFEL (6)" style="">
<b class="in">(6)</b>
<b class="is"></b>
<b class="ip">2.99</b>
<b class="iq"></b></a>
<a iid="128-74" class="itemsub lowend" price="4.99" name="FALAFEL (12)" style="">
<b class="in">(12)</b>
<b class="is"></b>
<b class="ip">4.99</b>
<b class="iq"></b>
</a>
<b class="is"></b>
<b class="ip"></b>
<b class="iq"></b>
</div>
</div>
</div>
Now I want to locate the first a tag by using nth-child(n) so I tried:
driver.find_element_by_css_selector('div#iopoph a:nth-child(2)').click()
But there is an error says:
NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"div#iopoph a:nth-child(2)"}
(Session info: chrome=79.0.3945.88)
Any friend can help?