如何在pycharm中编写xpath

时间:2015-08-06 15:09:43

标签: xpath pycharm

我有一个绝对的xpath:

的HTML /体/格[3] / DIV [4] / DIV / DIV [3] / DIV / DIV [3] / DIV / DIV [3] / DIV / DIV [3] / DIV / DIV [2 ] / DIV / DIV [2] / DIV / DIV [6] / DIV / DIV [5] / DIV / DIV [1] / DIV / DIV [2] / DIV [3] / DIV / DIV / DIV /表/ TBODY / TR [2] / TD [2]

和html代码是:

<div class="GGHMD25BMQH">
<table class="GGHMD25BJKC" style="width: 100%; cursor: pointer">
<tbody>
<tr>
<tr class="GGHMD25BHKC" recordid="100000001301800">
<td class="innerCell" cdn="0">
<td id="gwt-uid-660" class="innerCell" cdn="1" hover-area="true">Product Concept</td>
<td class="innerCell" cdn="2" hover-area="true">Comfort</td>
<td id="gwt-uid-662" class="innerCell" cdn="3" hover-area="true">Implantable Glucose Sensor</td>
<td id="gwt-uid-665" class="innerCell" cdn="4" hover-area="true">Glucose readings without painful finger sticks</td>
<td class="innerCell" cdn="5" hover-area="true">Implantable Sensor Concept Screener Q4</td>
<td class="innerCell" cdn="6" hover-area="true">Oct/2010</td>
<td class="innerCell" cdn="7" hover-area="true">
</tr>

我想在pycharm中编写一个xpath来标识这一行:<td id="gwt-uid-660" class="innerCell" cdn="1" hover-area="true">Product Concept</td>

1 个答案:

答案 0 :(得分:1)

由于通常id是唯一的,您可以尝试按id标识元素:

//td[@id='gwt-uid-660']