The function cy.should('have.css', 'width',...) does not return the value viewed on Chrome dev tool
See original GitHub issueCurrent behavior
Given an element has info css.width viewed on Chrome dev tool is 112.797px
Then I write this step verification: cy.get(...).should.('have.css', 'width', '112.797px)'
When I run the test on cypress, the cypress failed the above step as cypress detect the width is 112.796875px
Desired behavior
Cypress should returned the value width that is shown on Chrome dev tool
Test code to reproduce
Cypress Version
9.1.1
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
How to check if element width is less than or equal to a ...
I'd go with jQuery's outerWidth which is what you will usually want to check instead ... cy.get(selector).invoke('css', 'width') .then(str ...
Read more >How to Style console.log Contents in Chrome DevTools
This post demonstrates how to add CSS styling to the console output in DevTools.
Read more >Using Cypress
Cypress commands yield jQuery objects, so you can call methods on them. If you're trying to assert on an element's text content: cy.get('div ......
Read more >:has(): the family selector - Chrome Developers
In the shape of a :has() pseudo selector. The :has() CSS pseudo-class represents an element if any of the selectors passed as parameters...
Read more >An Intro to Web Site Testing with Cypress
Where you might need a ton of unit tests to get good coverage (the kind where you test that a function returns a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @sainthkh , I think they are the same element, as I have checked carefully on cypress and chrome dev tool. I use the same selector string, and I see that only one element is returned. Ah may be my test application has the issue on loading, which lead to the width changing. I just notice that. Thanks for your supporting. I will close this ticket
Do
querySelector()
and$el.get(0)
return the same element?