Warm tip: This article is reproduced from serverfault.com, please click

cypress-无法使用(Sypress框架)单击与另一个元素重叠的元素

(cypress - Can't click on an element that is overlapped by another element using (sypress framework))

发布于 2020-11-30 15:19:15

我想点击元素

        cy.visit('https://test.com:1111/')        
        cy.get('button').click()
        cy.contains('Configuration').click()
        cy.get('ant-tabs-tab').contains('Blocks').click()

但是此元素与另一个带有CypressError的元素重叠:

Timed out retrying: cy.click() failed because this element:
  <div role="tab" aria-disabled="false" aria-selected="false" class=" ant-tabs-tab"> Blocks </div>
is being covered by another element:
  <ul class="ant-menu menu ant-menu-dark ant-menu-root ant-menu-horizontal" role="menu" style="line-height: 64px;">...</ul>
Fix this problem, or use {force: true} to disable error checking.
Questioner
Александр
Viewed
0
Alapan Das 2020-12-01 00:38:27

你可以使用{force: true}withclick()禁用错误检查:

cy.visit('https://test.com:1111/')
cy.get('button').click({force: true})
cy.contains('Configuration').click({force: true})
cy.get('ant-tabs-tab').contains('Blocks').click({force: true})