如何单击 Cypress 中不可见的元素?

And*_*rio 11 automation cypress

我在 Cypress 中运行测试时遇到此错误:

Timed out retrying after 10050ms: cy.click() failed because this element is not visible:
Run Code Online (Sandbox Code Playgroud)

我怎样才能点击它呢?它只是一个菜单项,我不需要它在我的测试中可见。

Ala*_*Das 19

您必须添加{force: true}它应该使点击发生:

cy.get('locator').click({force: true})
Run Code Online (Sandbox Code Playgroud)