[英]How to click one button that exists multiple times with same name using cypress?
I have same button name on one page, how do handle that part?我在一页上有相同的按钮名称,如何处理该部分?
Not sure how to do it, Can anyone help?不知道该怎么做,有人可以帮忙吗?
This is possible, you can access the wanted button using.eq(), eg这是可能的,您可以使用.eq() 访问想要的按钮,例如
cy.get("div.confirm:visible").eq(0).click({ force: true });
This would get you the first button, eq(1) would get you the second button and so on.这将为您提供第一个按钮,eq(1) 将为您提供第二个按钮,依此类推。
If you use a CSS selector in cy.get
then you can append :first
or :last
to the CSS selector如果您在cy.get
中使用 CSS 选择器,那么您可以 append :first
或:last
到 CSS 选择器
eg例如
cy.get("div.foo:last").click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.