What i want to do is compare that the text in class "ellipsis-2-lines text-lg text-weight-semibold" is the same as h1 on next open page
this test throws an error: expected <h1.text-h4.text-weight-semibold.q-mb-sm> to contain @selectedText
I think there is an error when using invoke function. it might not even be possible to use it that way. How to fix this error?
describe('template spec', () => {
it('visit gxpbox', () => {
cy.visit('https://gxpbox.org/')
cy.get("input[placeholder=\"Where are you going?\"]").type("Dubai")
cy.get('[class="q-item q-item-type row no-wrap q-item--clickable q-link cursor-pointer q-focusable q-hoverable items-center"]').contains('Dubai, United Arab Emirates').click()
cy.get("button[type=\"submit\"]").click();
cy.get('[class="ellipsis-2-lines text-lg text-weight-semibold"]')
.should('have.length.gt', 19)
.its('length')
.then((n) => Cypress._.random(0, n - 1))
.then((k) => {
cy.log(`picked random index ${k}`)
cy.get('[class="ellipsis-2-lines text-lg text-weight-semibold"]').eq(k).click().invoke('text').as('selectedText');
})
cy.get('h1').should("contain", "@selectedText")
})
})