开发者

struggling to get right xpath for pop up image

I'm struggling to write a xpath which will help 开发者_如何学Gome finding image for popup.gif above based on known td element name, such as in this case "one" and "two".


Your question could be answered better with additional context. However if you are simply looking for the image tag which links to "popup.gif" assuming there is no URL you can use a pretty simple document-wide search:

//img[@src="popup.gif"]

If you a fully qualified URL or a relative URL not in the same folder is used to link to "popup.gif", and you aren't entirely sure what the URL will be in a given environment, you can use a regular expression match on the string of the src attribute.

//img[matches(@src, "popup\.gif")]

To use the name attribute to match, you can also do path-based matches as follows:

//td[@name="one"]/img

This will match the following structure.

<table>
  <tr>
    <td name="one">
       <img src="...."/>
    </td>
  </tr>
</table>

This expression may be excessively generic, it's highly dependent upon your document structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜