简体   繁体   English

{force: true} 是赛普拉斯中不可见元素的唯一方法吗?

[英]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.

相关问题 仅当 python 中的两个元素都为真时,我将如何检查和 append? - How will I check and append only if both elements are true in python? 有没有办法强制仅使用命名参数调用 function 或方法? - Is there a way to force a function or method to be called using named parameters only? 是否有更好的方法来绑定两个事件,但只有当两个事件都为真时才触发 - is there a better way to bind two events, but only triggers when either one is true 使 click() function 中的 {force:true} 成为默认行为 - Make {force:true} in click() function the default behavior JavaScript if语句仅返回true - Javascript if statement only returns true 仅当多个元素在视口中时才在它们上运行相同功能的最佳方法是什么? - What's best way to run same function on multiple elements only when they're inside viewport? R:是否有一种功能/简单的方法可以仅在包含数字作为字符的数据集元素中擦除空格? - R: Is there a function/easy way for erasing spaces in elements of a dataset only in those containing numbers as characters? 赛普拉斯 | 有没有办法让“it”测试从上次“it”测试结束的地方开始? - Cypress | Is there a way for an 'it' test to begin where the last 'it' test ended? 计算列表中要为其返回真值的元素 - Count elements in list for which a function returns true 只返回奇数元素 - Return only odd elements
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM