admin管理员组文章数量:1405365
I faced Cypress hover problem regarding access to a sub menu appearing after hovering on main menu item. The error is This element is not visible because it has CSS property: position: fixed and it's being covered by another element:
. I tried to use workarounds remended by Cypress but did not succeed. Cypress documentation says "Using .trigger() will only affect events in JavaScript and will not trigger any effects in CSS", so I tried to change CSS property of the element at first and then use .trigger mand:
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).invoke('attr', 'style', 'position: absolute');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).should('have.attr', 'style', 'position: absolute');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).invoke('show');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).trigger('mouseover');
but it did not work. Regardless I have confirmation expected <ul.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh> to have attribute style with the value **position: absolute**
I have the same error on the final step This element <ul.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh> is not visible because it has CSS property: **position: fixed** and it's being covered by another element:
. How can I access the hidden submenu without using { force: true }
argument?
I faced Cypress hover problem regarding access to a sub menu appearing after hovering on main menu item. The error is This element is not visible because it has CSS property: position: fixed and it's being covered by another element:
. I tried to use workarounds remended by Cypress https://docs.cypress.io/api/mands/hover#Workarounds but did not succeed. Cypress documentation says "Using .trigger() will only affect events in JavaScript and will not trigger any effects in CSS", so I tried to change CSS property of the element at first and then use .trigger mand:
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).invoke('attr', 'style', 'position: absolute');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).should('have.attr', 'style', 'position: absolute');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).invoke('show');
cy.get('.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh').eq(0).trigger('mouseover');
but it did not work. Regardless I have confirmation expected <ul.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh> to have attribute style with the value **position: absolute**
I have the same error on the final step This element <ul.header-module--subMenu--1TF98.header-module--menuLevel2--2QGyh> is not visible because it has CSS property: **position: fixed** and it's being covered by another element:
. How can I access the hidden submenu without using { force: true }
argument?
2 Answers
Reset to default 5Something might be wrong with the selector, since you set position: absolute
and confirm it, yet the message still references position: fixed
.
Assuming the selector is ok, you might be able to trigger the "show" effect with .realHover()
from cypress-real-events.
It uses Chrome Devtools Protocol to automate the chrome devtools (only for chrome browser).
I was facing the same problem like that but u can resolve(works for me) it, see the below steps.
- install cypress-real-events -> npm i cypress-real-events or npm i cypress-real-events --f.
- import this statement -> import "cypress-real-events"; into your mands.js or index.js whichever u have in under your support folder.
- Now use it like this -> cy.get(".cssmenu > :nth-child(1)").realHover();
Hope this will help u guys.
本文标签: javascriptHow to overcome hover issue in CypressStack Overflow
版权声明:本文标题:javascript - How to overcome hover issue in Cypress? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744215125a2595602.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论