gpt4 book ai didi

xpath - Xpath:选择与三个子属性匹配的父链接

转载 作者:行者123 更新时间:2023-12-03 16:40:19 25 4
gpt4 key购买 nike

我需要使用xpath选择一个匹配以下三个条件的链接:

父@class ='testItem'

子@class ='icon icon_checked'

文字=“测试文字在这里!”

我不确定将文本属性放在xpath引用中的位置。我尝试了以下多种排列方式:

//a[@class="testItem" and child::span[@class="icon icon_checked"] and li[text()="test text goes here!"]]


我的问题是文本部分不在自己的范围内。

这是原始示例:

<li>
<a class="testItem2" data-code="2" href="javascript:void(0);">
<span class="icon icon_checked"></span>
test text goes here2!
</a>
</li>

<li>
<a class="testItem" data-code="2" href="javascript:void(0);">
<span class="icon icon_checked"></span>
test text goes here!
</a>
</li>

最佳答案

谢谢您的帮助。我找到了答案。

我可以简单地将xpath的最后一部分从li [text()=“ test text go here!”]更改为。[text()=“ test text go here!”]]。

我最后的工作xpath是:

//a[@class='testItem' and child::span[@class='icon icon_checked'] and .[text()='test text goes here!']]

关于xpath - Xpath:选择与三个子属性匹配的父链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15749657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com