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

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

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

I want to click on the element

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

but this element is overlapped by another element with 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

You can use {force: true} with click() to disable error checks:

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})