question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The function cy.should('have.css', 'width',...) does not return the value viewed on Chrome dev tool

See original GitHub issue

Current 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

image

image

Cypress Version

9.1.1

Other

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
thienthu1410commented, Dec 10, 2021

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

0reactions
sainthkhcommented, Dec 8, 2021

Do querySelector() and $el.get(0) return the same element?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found