如何在网格中与XPath的网格中的同一行中找到链接
我需要单击网格中包含特定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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设图像和链接在相同的
tr
元素内包含图像,其余的然后选择可单击的元素相对于该元素。
如果它们在
tr
之外的其他东西中,请相应地调整。Assuming that the image and the link are inside the same
tr
element, you could combine them like this: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.所以我终于自己想出了这一点:我需要的XPath是:
So I finally figured this out myself: The xpath I needed is: