gpt4 book ai didi

css - xpath [last()] 方法中的模糊错误

转载 作者:行者123 更新时间:2023-11-28 18:06:59 28 4
gpt4 key购买 nike

在 cucumber 的自定义步骤中,我这样写:

find(:xpath ,"//ul//input[@placeholder = 'Enter Something'][last()]").set(value)  

而且我收到正则表达式不明确的匹配错误:它正在获取两个元素。我怎样才能在 cucumber 中使用 xpath(或者甚至是 css)获取这个元素??

我正在使用 cucumber-1.2.1capybara-2.0.3

(请注意:以上两个输入字段中的每个属性都是相同的)

HTML:

<ul class = "someclass">
<li>
<div>
<a></a>
<input></input>
<input placeholder = "Enter Something"></input>
</div>
</li>
<li>
<div>
<a></a>
<input></input>
<input placeholder = "Enter Something"> // This is the element I want
</input>
</div>
</li>
</ul>

最佳答案

您的 xpath 中需要一组额外的括号:

"(//ul//input[@placeholder = 'Enter Something'])[last()]"

关于css - xpath [last()] 方法中的模糊错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19447897/

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