hi folks as i am new into this cypress and UI automation I need your help in resolving current scenario
i have a grid like this
i have created a
custom command
in support\commands.js
below is my code which take OrderID
as parameter and read the Freight info
from ui but it has lot of nested div
tab for padding hence i use parents()
tag to reach the specific index row
Cypress.Commands.add('readFreightInfo', (OrderID) => {
return cy.get('.simple-table__cell:nth-child(1)')
.contains(OrderID)
.parents("div[role='row']")
.find('div')
.eq(2)
.invoke('text')
})
but the text it is returning is '\n 65.88'
what i needed
i needed the number part only i.e. 299.88 in Number type
as it was a generic method for validation i was using earlier
cy.readFreightInfo(10250).should('eq', 65.83)
but now I want to assert it as the returning value of custom command
should lies between 60 and 70
what i have tried so far
i have tried using both the workaround mentioned on this answer