I'm new to Cypress and I need to compare theese two numbers: 1045,92 and 1045,92
<div class="header-icon__text" data-pl-cart-in-
total>1 045,92 р.</div>
<span>1 045,92 р.</span>
I try like this
cy.xpath("").invoke('text').then((text1) => {
cy.xpath("").invoke('text').then((text2) => {
expect(text1).to.deep.equal(text2);
But:
AssertionError:
expected '1 045,92 р.' to deeply equal '1 045,92 р.'
And I try like this:
cy.xpath("").invoke('text').then((text1) => {
cy.xpath("").invoke('text').then((text2) => {
expect(Math.floor(text1)).to.deep.equal(Math.floor(text2));
assert expected NaN to deeply equal NaN
But:
I'm not sure that NaN is 1 045,92
I guess u pass these values as a string? But if you compare them string-like or number-like shouldn't matter, values should be identical.
And
NaNis due to the,(and the space between 1 and 0) as this should be a., like1045.92.NaNmeansNot a Numbermeaning your casting (Math.floor()) fails due to prior reasons.