mercredi 18 novembre 2020

Cypress: compare two columns together: column value and date value

enter image description here

I have to check first the value of the status column with new, processing values to then be able to compare the dates.

if I have to compare a new vs processing data, the new date will be greater than the processing date. since the data is sorted by order first by value and then by date ascending. So if I find two values with the usual status I can make the following comparison:

    cy.get('#hometable > tbody > tr > td:nth-child(6)').each(($e, index, $list) => {
        if (index == 0){time_prev=0}
        time = Math.round(new Date($e.text()).getTime() / 1000)
        assert.isBelow(time_prev, time, 'previous date is below actual')
        time_prev = time
    })


 //so I take the value status
 cy.get('#hometable > tbody > tr > td:nth-child(5)').each(($e, index, $list) => {
        const text = $e.text()
        if (text.includes('new')) {
            expect(text).to.eq('\n                                                              new\n                                                           ')

        }
        if (text.includes('processing')) {
            expect(text).to.eq('\n                                                              processing\n                                                           ')
        }

    })

I should be able to make the two comparisons together in a single cycle but I have no idea where to start

i give following error:

enter image description here

Aucun commentaire:

Enregistrer un commentaire