【发布时间】:2021-01-20 12:55:11
【问题描述】:
当页面上存在 tile 元素时,此代码可以完美运行,但我试图在不同页面上运行相同的测试。因此,一些页面没有“平铺”元素标签。 如果元素不存在,我正在尝试找到一种跳过这段代码的方法。感谢您抽出时间来研究它。 HERE is the screenshot of the code
if ((cy.get('bx--tile') {
.its('length').should('be.gt', 0))) {
cy.get('bx--tile').each(($el, index, $list) => {
let url = $el.attr('data-href');
if (url) {
let options = Object.assign({}, {url: url});
cy.request(options).then(resp => {
expect(resp.status).to.eq(200);
});
}
});
}
}
【问题讨论】:
-
尝试stackoverflow.com/questions/56145926/…中提到的解决方案
标签: testing automation conditional-statements rendering cypress