I'm using Selenium python to try to find out all the descendant under the first div, so I used this code:
label_element =driver.find_elements_by_xpath("//div[@style='display:block']/descendant::label")
But get an empty list [].
<div id="coption5" class="copt" style="display: block;">
<div style="height:100%;display:flex;align-items:center;justify-content:center;">
<div class="coptw">
<div style="width:100%;height:49px;border-bottom:1px solid #888">
<b class="cpopdish">SUPREME CALZONE (M) 10.99</b>
<b class="cpopmodifi gray" data-iid="0" style="font-weight: normal;">
<i class="fa fa-comments-o"></i> Special Request</b><b class="cpopprice">10.99</b></div>
<div class="comain" style="right: 0px;">
<div class="crow" grp="0" grpname="">
<label class="label0" cid="5" style="">
<input type="radio" name="0" coname="BF PEPPERONI(M)" sname="" price="0.00" value="2">BF PEPPERONI(M)<b class="ip">0.00</b>
</label>
<label class="label0" cid="5"><input type="radio" name="0" coname="BLACK OLIVES(M)" sname="" price="0.00" value="3">BLACK OLIVES(M)<b class="ip">0.00</b>
</label>
<label class="label0" cid="5"><input type="radio" name="0" coname="CHICKEN(M)" sname="" price="1.00" value="4">CHICKEN(M)<b class="ip">1.00</b>
</label>
<div style="clear:both"></div></div>
</div><a class="ocancel" data-cid="5" data-grps="0"><i class="fa fa-remove"></i> Cancel</a></div></div>
Any friend know how to use Xpath or Css selector to locate all the label tag?
this first part of my code:
driver.find_elements_by_xpath("//div[@style='display:block']")
Can locate the first div element successfully so I think maybe there is nothing wrong with the visibility issues. The label tag is inside the first div tag, label are the descendant of the first div.
So any friend can help?