如何在网格中与XPath的网格中的同一行中找到链接

发布于 2025-02-13 20:50:16 字数 341 浏览 0 评论 0原文

我需要单击网格中包含特定IMG的网格中的链接。我可以轻松地找到我想要的正确的IMG:

// img [@src ='。/assets/images/not_evaLET.SVG']

但是,当我对其进行单击时,它不起作用,因为图像无法单击。但是,同一行包含我要单击的链接。单击链接的XPath是:

// a [@class ='veracodelink'] // span [contains(text(),'static scan'')]

我需要组合这2个X Paths以获取正确的链接以单击。我尝试了许多不同的事情和组合,但似乎没有任何作用。

I need to click a link in a grid that contains a particular img on the same row. I can easily find the correct img I want with:

//img[@src='./assets/images/not_evaluated.svg'].

However, when I issue the click with it, it doesn't work because the image is not clickable. However, the same row contains the link I want to click. The xpath to the clickable link is:

//a[@class='veracodelink']//span[contains(text(),'Static Scan')].

I need to combine these 2 xpaths to get the correct link to click. I have tried many different things and combinations, but nothing seems to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

|煩躁 2025-02-20 20:50:16

假设图像和链接在相同的tr元素

//tr[.//img[@src='./assets/images/not_evaluated.svg']]//a[@class='veracodelink']//span[contains(text(),'Static Scan')]

内包含图像,其余的然后选择可单击的元素相对于该元素。

如果它们在tr之外的其他东西中,请相应地调整。

Assuming that the image and the link are inside the same tr element, you could combine them like this:

//tr[.//img[@src='./assets/images/not_evaluated.svg']]//a[@class='veracodelink']//span[contains(text(),'Static Scan')]

Explained: //tr[...] here selects the correct row containing the image, and the rest then selects the clickable element relative to that.

If they are inside something else than tr, adjust accordingly.

避讳 2025-02-20 20:50:16

所以我终于自己想出了这一点:我需要的XPath是:

//div//vc-link//a[@class='veracodelink']//span[contains(text(), 'Static Scan')][../../../../../..//img[@src='./assets/images/not_evaluated.svg']]

So I finally figured this out myself: The xpath I needed is:

//div//vc-link//a[@class='veracodelink']//span[contains(text(), 'Static Scan')][../../../../../..//img[@src='./assets/images/not_evaluated.svg']]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文