基于文本的跨度的 XPath?

新手上路,请多包涵

我无法使用我尝试过的 XPath 找到第一个跨度:

 //*[@id='student-grid']/div[2]/div[1]/table/tbody/tr[1]/td/span/span[contains(text(), 'Edit School')]

选择带文本的跨度 - 编辑学生按钮

 <tbody role="rowgroup">
<tr class="" data-uid="2f3646c6-213a-4e91-99f9-0fbaa5f7755d" role="row" aria-selected="false">
<td class="select-row" role="gridcell">
<td class="font-md" role="gridcell">marker, Lion</td>
<td role="gridcell">TESTLINK_1_ArchScenario</td>
<td role="gridcell">1st</td>
<td role="gridcell">Not Started</td>
<td role="gridcell"/>
<td role="gridcell"/>
<td role="gridcell">QA Automation TestLink Folders</td>
<td class="k-cell-action" role="gridcell"/>
<td class="k-cell-action detail-view-link font-md" role="gridcell">
<span class="button-grid-action kendo-lexia-tooltip icon-pencil" role="button" title="Edit Student">
<span>Edit Student</span>
</span>
</td>
<td class="k-cell-action archive-link font-md" role="gridcell">
<span class="button-grid-action kendo-lexia-tooltip icon-archive" role="button" title="Archive Student">
<span>Archive Student</span>
</span>
</td>
</tr>
</tbody>

原文由 Rock 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 234
1 个回答

如果你想 select span with text - Edit Studen 试试这个:

 //span[@title='Edit Student']/span
//span[text()='Edit Student']

如果你想选择 Edit Studen with role="button" 试试这个:

 //span[@title='Edit Student'][@role='button']
//span[@role='button'][./span[text()='Edit Student']]
//span[@role='button'][./span[.='Edit Student']]

原文由 Vitaliy Moskalyuk 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏