Concatenate The Found Text Using Cypress Aliases

Concatenate The Found Text Using Cypress Aliases

gleb bahmutov

1 год назад

1,134 Просмотров

In this video, I show how to extract multiple text fragments from the page and save them under aliases. Then we can get all the aliased values while avoiding a pyramid of callbacks.

cy.get('#noun').invoke('text').as('noun')
cy.get('#verb').invoke('text').as('verb')
cy.get('#adjective').invoke('text').as('adjective')
cy.then(function () {
const s = `${this.noun} ${this.verb} ${this.adjective}`
expect(s, 'concatenated string').to.equal(
'a brown fox jumped slow',
)
})

Find this recipe at my site https://glebbahmutov.com/cypress-examples
Ссылки и html тэги не поддерживаются


Комментарии: