作为 Selenium 实践的一部分,需要在 SPAN 标记内找到 "hardware" 文本 HTML
Need to locate "hardware" text inside SPAN tag as part of Selenium practice from the below HTML
<li>
<button>
<span>software</span>
<value>high risk</value>
</button> <button>
<span>hardware</span>
<value>moderate risk</value>
</button> <button>
<span>software</span>
<value>low risk</value>
</button>
<button>
</li>
我写了
//*[contains(@value, 'moderate risk']//preceding::span
尝试使用 Chropath,但它显示 "This element might be inside iframe from different src. Currently ChroPath doesn't support for them."
由于是练习,我将其保存为 html 文件
value
是这里的标签而不是 attribute
尝试以下 xpath.
//*[contains(text(), 'moderate risk')]//preceding-sibling::span
我也可以使用下面的 xpath 找到它,这与@kunduk 发布的类似。
//*[contains(text(), 'moderate risk')]/preceding::span[1]
<li>
<button>
<span>software</span>
<value>high risk</value>
</button> <button>
<span>hardware</span>
<value>moderate risk</value>
</button> <button>
<span>software</span>
<value>low risk</value>
</button>
<button>
</li>
我写了
//*[contains(@value, 'moderate risk']//preceding::span
尝试使用 Chropath,但它显示 "This element might be inside iframe from different src. Currently ChroPath doesn't support for them."
由于是练习,我将其保存为 html 文件
value
是这里的标签而不是 attribute
尝试以下 xpath.
//*[contains(text(), 'moderate risk')]//preceding-sibling::span
我也可以使用下面的 xpath 找到它,这与@kunduk 发布的类似。
//*[contains(text(), 'moderate risk')]/preceding::span[1]