I am using BDD with Cypress. The element I want to check is
So this element is on the PageObject:
allowPriceEmbeddedBarcodeAtPOS(){
return cy.get('im-data-table.hydrated').shadow().find('tr:nth-child(2) > td:nth-child(2)')
}
And on the Step Definition file I have:
And("Global Configuration is set true", () => {
platformadmin.allowPriceEmbeddedBarcodeAtPOS().should('contains.text','{"AllowPriceEmbeddedBarcodeAtPOS": true}')
})
But when I run cypress it founds the element with \n\t
Any ideas how can I remove this?
You can use a regex with \s
to remove all whitespace
platformadmin.allowPriceEmbeddedBarcodeAtPOS()
.then($el => $el.text().replace(/\s/g, ''))
.should('eq','{"AllowPriceEmbeddedBarcodeAtPOS":true}')
Ref Cypress recipe have-attr-assertion