【问题标题】:CypressError: cy.click() failed because this element is being covered by another elementCypressError:cy.click() 失败,因为此元素被另一个元素覆盖
【发布时间】:2021-12-10 20:28:39
【问题描述】:

所以我正在尝试运行赛普拉斯测试,用户转到右上角的下拉菜单并单击“我的设置”,然后单击名为“隐私政策”的链接:

it.only('2.5 - Press "Privacy Policy" on the "My Settings" screen. - "Armadillo Privacy Policy" screen is displayed', () => {
  cy.login()

  cy.get('body div button[data-cy=usermenubutton]')
    .click()
    .get('body div ul li[data-cy=mySettings]')
    .contains('My Settings')
    .click()

  cy.get('a[href="/legal/privacy"]')
    .click()

  cy.screenshot()
})

但是,无论我如何重构,我都会继续收到此错误:

cy.click() failed because this element:

<a class='MuiTypography-root-bwkfm MuiTypography-root MuiTypography-inherit MuiTypography-root-dfghjk MuiLink-root MuiLink-underlineAlways" href="/legal/privacy">Privacy...</a>

is being covered by another element:

<div aria-hidden="true" class="MuiBackdrop-root-fghjkl hjk MuiBackdrop-root MuiBackdrop-invisible MuiModal-backdrop-klghjkhg tyutyu style="opacity: 1; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"></div>

Fix this problem, or use {force: true} to disable error checking.

【问题讨论】:

    标签: cypress


    【解决方案1】:

    由于您的元素被另一个元素覆盖,您可以使用click({force: true}),禁用错误检查并执行点击。

    cy.get('a[href="/legal/privacy"]').click({force: true})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-29
      • 2013-06-06
      • 2022-08-18
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多