79282046

Date: 2024-12-15 09:02:38
Score: 0.5
Natty:
Report link

Taking the cue in the suggested answer, to pass the variable to a .then(), I have restructured the code, it is now working as expected.

Then('the total amount I have sent to {string} so far is {string}', (toCountry, amountSent) => {

    let amountSentTotal = 0

    trackTransfersPageObj.getRecordCount.each($el => {

        let amountSent = $el.find('td:nth-of-type(5):contains("' + toCountry + '")').next('td').text().trim().replace(/[£N,]/g, '')
        amountSentTotal = Number(amountSentTotal) + Number(amountSent)

    }).then(function () {
        expect(amountSentTotal).equal(Number(amountSent))
    })

})
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: unlisted