这是xml的一个片段。我需要使用selenium来查找引用ID值 1616968600 ,但我是xpath的新手,我可以使用一些帮助。
<div class="row">
.....
</div>
<div class="row">
<div class="col-md-2 ng-scope" style="font-weight: bold" translate="Business_Partner_Id">Business partner name: </div>
<div class="col-md-2 ng-binding">Avnet Hall-Mark</div>
<div class="col-md-2 ng-scope" style="font-weight: bold" translate="Quote_Id">Quote ID: </div>
<div class="col-md-3 ng-binding">1616968600</div>
</div>
答案 0 :(得分:3)
找到包含div
文字的Quote ID
并获取next sibling:
//div[contains(., "Quote ID")]/following-sibling::div
用法:
quote_id_elm = driver.find_element_by_xpath('//div[contains(., "Quote ID")]/following-sibling::div')
print(quote_id_elm.text)