【发布时间】:2022-01-25 22:29:45
【问题描述】:
<a href="/pro/2/len.html" class="lol-link" href="/pro/2/len.html"> <span hide="trololo"> <img class="prod" ng-src="https://med.png" alt="Len" src="https://med.png"> </span> <span ng-hide="index" class="ng-hide"> <span>Len</span> </span> </a>
我的 xpath:
"//span[contains(text(), 'Len')]/preceding-sibling::span"
我想找到文本“Len”,但不幸的是我的 xpath 不起作用。有人可以帮忙吗?
【问题讨论】:
-
在我看来像
//span[.='Len'],但也许有什么你没有告诉我们的? -
或
//a[@class="lol-link"]/span[2]/span,在此超链接之前可能还有更多内容。 -
@simpleApp,@MichaelKay 不起作用。我试过
//span[contains(@class,'ng-hide')]/preceding-sibling::span并且它有效,但我不知道如何到达'Len' -
我想定位文字'Len',但在什么条件下?