如何在下面的代码中写关闭按钮的xpath?

时间:2012-06-12 08:18:41

标签: firebug

我正在使用firebug工具:

我试过“// table [@ class ='x-btn-medium x-btn-icon-medium-left'] / em / button”,但它没有用。这是正确的方法吗?如果错了,plzz让我知道wat是正确的吗?

此命令中的

ext-gen251是动态的。

<button id="ext-gen251" class=" x-btn-text" type="button">Close</button>

以下是代码:

<div id="ext-comp-1089" class=" x-window" style="position: absolute; z-index: 9003; visibility: visible; left: 500px; top: -39px; width: 600px; display: block;">
        <div class="x-window-tl">
        <div class="x-window-tr">
        <div class="x-window-tc">
        <div id="ext-gen192" class="x-window-header x-unselectable x-window-draggable" style="-moz-user-select: none;">
        <div id="ext-gen198" class="x-tool x-tool-close">&nbsp;</div>
        <span id="ext-gen203" class="x-window-header-text">Details</span>
        </div>
        </div>
        </div>
        </div>
        <div id="ext-gen193" class="x-window-bwrap">
        <div class="x-window-ml">
        <div id="ext-gen196" class="x-window-bl">
        <div class="x-window-br">
        <div class="x-window-bc">
        <div id="ext-gen195" class="x-window-footer x-panel-btns" style="width: 576px;">
        <div id="ext-comp-1090" class="x-panel-fbar x-small-editor x-toolbar-layout-ct" style="width: auto;">
        <table class="x-toolbar-ct" cellspacing="0">
        <tbody>
        <tr>
        <td class="x-toolbar-left" align="left">
        <td class="x-toolbar-right" align="right">
        <table class="x-toolbar-right-ct" cellspacing="0">
        <tbody>
        <tr>
        <td>
        <table cellspacing="0">
        <tbody>
        <tr class="x-toolbar-right-row">
        <td id="ext-gen250" class="x-toolbar-cell">
        <table id="ext-comp-1091" class="x-btn jxCancelBtn x-btn-noicon" cellspacing="0" style="width: 75px;">
        <tbody class="x-btn-medium x-btn-icon-medium-left">
        <tr>
        <tr>
        <td class="x-btn-ml">
        <td class="x-btn-mc">
        <em class="" unselectable="on">
        <button id="ext-gen251" class=" x-btn-text" type="button">Close</button>
        </em>
        </td>
        <td class="x-btn-mr">
        </tr>
        <tr>
        </tbody>
        </table>
        </td>
        </tr>
        </tbody>
        </table>
        </td>
        <td>
        </tr>
        </tbody>
        </table>
        </td>
        </tr>
        </tbody>
        </table>
        </div>
        <div id="ext-gen200" class="x-clear"></div>
        </div>
        </div>
        </div>
        </div>
        </div>

1 个答案:

答案 0 :(得分:1)

你很接近,但看起来不是//table[@class='x-btn-medium x-btn-icon-medium-left']/em/button你应该// tbody [@class='x-btn-medium x-btn-icon-medium-left']//em/button,因为那是class = x-btn-medium x-btn-icon-medium-left

我还将结尾部分从/em/button更改为//em/button,因为在html中似乎有相当多的垃圾。