CypressError: cy.click() failed because this element is being covered by another element
CypressError: cy.click() failed because this element is being covered by another element
所以我正在尝试 运行 赛普拉斯测试,用户进入右上角的下拉菜单并单击“我的设置”,然后单击名为“隐私政策”的 link:
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.
由于您的元素被另一个元素覆盖,您可以使用 click({force: true})
来禁用错误检查并执行点击。
cy.get('a[href="/legal/privacy"]').click({force: true})
所以我正在尝试 运行 赛普拉斯测试,用户进入右上角的下拉菜单并单击“我的设置”,然后单击名为“隐私政策”的 link:
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.
由于您的元素被另一个元素覆盖,您可以使用 click({force: true})
来禁用错误检查并执行点击。
cy.get('a[href="/legal/privacy"]').click({force: true})