[英]Is {force: true} the only way for invisible elements in Cypress?
Is there any alternative way apart from {force: true} on click & type function for the elements not visible in the web application using Cypress?除了 {force: true} 之外,对于使用 Cypress 的 web 应用程序中不可见的元素,单击并键入 function 是否有其他方法?
Using {force:true} on each & every function doesn't seem to be an ideal way.在每个 function 上使用 {force:true} 似乎不是一种理想的方式。 Any thoughts team?
有想法的团队吗?
You can use .should('be.visible')
like:您可以像这样使用
.should('be.visible')
:
cy.get('#element-id').should('be.visible').click()
You can use .wait()
like:您可以像这样使用
.wait()
:
cy.get('#element-id').wait(2000).should('be.visible').click()
You can use .then()
like;你可以使用
.then()
类的;
cy.get('#element-id').then(($el) => {
if ($el.is(':visible')) {
$el.click()
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.