包含 2 个子元素的 XPath 元素,每个子元素都匹配特定文本 [英] XPath Element that contains 2 children that each match a specific text

查看:21
本文介绍了包含 2 个子元素的 XPath 元素,每个子元素都匹配特定文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium 定位页面上的某些元素.

I'm using Selenium to target certain elements on a page.

我有一张看起来像这样的桌子

I have a table that looks like this

<table>
    <tbody>
         <tr>
             <td>Text1</td>
             <td>Text2</td>
         </tr>
         ...
    </tbody>
</table>

每个 元素都匹配这个模式.我想传入两个字符串,text1 &text2,并按该顺序查找其两个单元格与 text1 和 text2 匹配的行元素.我假设 XPath 是要走的路,如果可能的话,我只是不确定如何编写这个案例.

Each <tr> element matches this pattern. I want to pass in two strings, text1 & text2, and find the row element whose two cells match text1 and text2, in that order. I'm assuming XPath is the way to go, I'm just not really sure how to write this case, if it's possible.

推荐答案

谓词可以组合:

//tr[td[1]="Text1" and td[2]="Text2"]

这篇关于包含 2 个子元素的 XPath 元素,每个子元素都匹配特定文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆