页面上有两个相同的元素,如何使用 watir 单击第二个元素?
页面上有 2 个图像具有相同的图像 src 链接。如果我使用以下代码,它将单击第一个图像,那么如何单击第二个图像?
browser.image(:src, "https://itc.mzstatic.com/itc/images/btn-grey-small-edit.png").click
There are 2 images on a page that have the same image src link. If i use the following code it will click the first image, so how do I click on the second image?
browser.image(:src, "https://itc.mzstatic.com/itc/images/btn-grey-small-edit.png").click
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要捕获所有图像,然后单击第二个图像
或指定图像的索引(对于 watir-webdriver,索引从 0 开始,对于 watir,索引从 1 开始):
You need to either capture all images, and click the second one
or specify the index of the image (index starts at 0 for watir-webdriver, or 1 for watir):