Cypress browser tab renders css differently than non-Cypress controlled tab #17844
Unanswered
reposman33
asked this question in
Component Testing
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a login page. It displays a username/ pw form and an empty navbar on top. When I succesfully authenticate by entering username / pw the navigation buttons and a Log out button are rendered in the navbar.
When I manually log in it's like this:
| |
Notice that after succesfully signing in, the buttons in the navbar are visible. I wrote a Cypress test doing just that. It fills in the username / pw, clicks the "Log in" button. Then it checks if the buttons are visible. But the navbar stays empty and the test fails.
The error message Cypress shows (after the built in 40000 ms delay):
<button.button.is-danger.has-text-weight-bold> refers to the Log out button. It is the first in the list of buttons to test the visibility in the Cypress test. When I remove that button from the test and re-run the test, the next button triggers this error message.
I expect the navigation buttons and the Log out button to appear, as happens when I manually log in.
This is my html of the navbar
this is the Cypress test:
When I inspect the html using developer tools I see the property
display: none
on thediv.navbar-menu
element containing the buttons. This property is also present when I manually log in in a browser window but its children (div.menu-start and div.menu-end) have a propertydisplay: flex
, overruling the parent'sdisplay: none
and effectively showing the navigation and logout buttons.Below the relevant html in the browser tab controlled by Cypress after the test is run:
Notice the css property display:none and the greyed-out children containing the buttons, meaning their css display property is not set.
Below the html rendered in Cypress controlled tab:
:
The navbar is empty.
Below the same html snippet after I manually logged in:
Notice the css property
display:none
but the children containing the buttons are not greyed-out, meaning their css display property is notnone
.html rendered:
notice the buttons in the navigation bar
How can I have Cypress see these DOM elements and have the test succeed?
Cypress v8.3.0
Using the Bulma css framework v 0.9.3
Built with Angular 12.1.4
Firefox 91 used by Cypress and me
Beta Was this translation helpful? Give feedback.
All reactions