【发布时间】:2021-02-03 11:38:49
【问题描述】:
我正在使用 cypress 来测试我的网站,我想要实现以下目标: 在此链接下:https://www.glassboxdigital.shop/product-page/classic 当我点击“添加到购物车”时
我想点击“查看购物车”按钮,我的第一次尝试是天真的 - 获取元素定位器并点击它,因为我看到它失败了,我调查了一下,发现它是“iframe”我尝试使用“iframe”,指出如下:
cy.get("iframe[frameborder='0']:nth-child(2)").then(function($elem){
var ifele = $elem.contents().find("a[id*='view-cart-button']")
cy.wrap(ifele).click()
但是当我运行它时,结果是:
Expected to find element: undefined, but never found it
cy.get("iframe[frameborder='0']:nth-child(2)").then(function($elem){
16 | var ifele = $elem.contents().find("a[id*='view-cart-button']")
> 17 | cy.wrap(ifele).click()
| ^
18 | })
19 |
20 | }
【问题讨论】:
标签: selenium iframe cypress ui-testing