How can I store the text value of a div once and use this throughout a cypress test?
Thus far I\'ve managed to do this by nesting the bulk of my test\'s logic within the
Your code will not work as you are not doing the operation within chain. Cypress works in promise chain and that's how the architecture is.... You have to pass on values to chain and do the operation accordingly.
It will work like below.
return cy.get(`.locatorClassName`).then(ele => {
return ele.text()
}).then(eleValue => {
cy.log(eleValue);
});