Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 正确使用xpath轴定位_Html_Xpath_Selenium_Selenium Webdriver - Fatal编程技术网

Html 正确使用xpath轴定位

Html 正确使用xpath轴定位,html,xpath,selenium,selenium-webdriver,Html,Xpath,Selenium,Selenium Webdriver,我正在测试一个带有动态ID的网页。该页面在多个位置包含一个删除图标和一个浏览图标,我无法单击这些图标,或者我必须说我无法编写正确的XPath来定位任何特定图标 下面是HTML代码的一个片段 <tr class="tableNestedAttribute"> <td class="autosuggest-svl-cell"> <input name="odf_obs_fin_dept_text"> <div id="

我正在测试一个带有动态ID的网页。该页面在多个位置包含一个删除图标和一个浏览图标,我无法单击这些图标,或者我必须说我无法编写正确的XPath来定位任何特定图标

下面是HTML代码的一个片段

<tr class="tableNestedAttribute">
    <td class="autosuggest-svl-cell">
        <input name="odf_obs_fin_dept_text">
        <div id="div_d31505e760_location"></div>
    </td>
    <td class="actions" nowrap="" align="right">
        <div class="ui-browse-lookup-images ppm_field formFieldDisNoWidthReadOnly ">
            <img id="d31505e7601" title="Remove Department OBS" name="Remove">
            <img id="d31505e7600" title="Browse Department OBS" name="Browse">
        </div>
    </td>
</tr>

在提供的示例中,使用以下XPath:

//input[@name='odf_obs_fin_dept_text']/parent::td/following-sibling::td[1]/div/img[@name='Browse']
将找到下一个元素:

<img id="d31505e7600" title="Browse Department OBS" name="Browse">
<img id="d31505e7600" title="Browse Department OBS" name="Browse">
//*[@name='odf_obs_fin_dept_text']/parent::td/following-sibling::td[1]/descendant::div/img[@name='Browse']