如何在pycharm中编写xpath [英] How to write xpath in pycharm

查看:133
本文介绍了如何在pycharm中编写xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对的 xpath:

html/body/div[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/table/tbody/tr[2]/td[2]

和html代码是:

<table class="GGHMD25BJKC" style="width: 100%; cursor: pointer"><tr><tr class="GGHMD25BHKC" recordid="100000001301800"><td class="innerCell" cdn="0"><td id="gwt-uid-660" class="innerCell" cdn="1" hover-area="true">产品概念</td><td class="innerCell" cdn="2" hover-area="true">舒适度</td><td id="gwt-uid-662" class="innerCell" cdn="3" hover-area="true">植入式葡萄糖传感器</td><td id="gwt-uid-665" class="innerCell" cdn="4" hover-area="true">血糖读数没有疼痛的指尖</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">产品概念

解决方案

由于通常id是唯一的,你可以尝试通过id来识别元素:

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

I have a absolute xpath:

html/body/div[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/table/tbody/tr[2]/td[2]

and the html code is:

<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>

I want to write an xpath in pycharm to identify this line : <td id="gwt-uid-660" class="innerCell" cdn="1" hover-area="true">Product Concept</td>

解决方案

Since commonly id is unique, you can try to identify the element by id :

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

这篇关于如何在pycharm中编写xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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