XPath到同一行的表格单元格?

时间:2017-11-28 16:50:29

标签: python html xml selenium xpath

我可以找到textA,但我需要找到该行中的复选框。所以我的想法是为tr找到textA,然后在tr下搜索元素复选框。任何人都可以帮我详细说明XPath查询吗?

  <tbody class = "table">
        <tr class ="rows">
            <td class= "colmn">
                <div class = "textA">
            <td class= "colmn">
                <div class = "image">   
            <td class= "colmn">
                <div class = "drop down">
            <td class= "colmn">
                <div class = "checkbox">
        <tr class ="rows">
            <td class= "colmn">
                <div class = "textC">
            <td class= "colmn">
                <div class = "image">   
            <td class= "colmn">
                <div class = "drop down">
            <td class= "colmn">
                <div class = "checkbox">

2 个答案:

答案 0 :(得分:1)

这个XPath,

//tr[td/div/@class='textA']/td/div[@class='checkbox']

将根据要求选择divclass='checkbox' tr td/div class='textA' setState。{/ p>

答案 1 :(得分:0)

您可以尝试: - //div[@class="textA"]/ancestor::tr//*[@class="checkbox"]