I want to use a value that i got from a website and stored in a variable outside of a "within" function to comapre it with another value.
cy.get('.TableCloumn_3')
.within($tr => {
cy.get('[class="ng-star-inserted"]').then(($span) => {
const relRep = $span.text();
cy.log(relRep);
})
})
cy.log(relRep)
})
The first cy.log for relRep prints me the value but the second one does not. When I change from it from cont to var it also gives me an empty log. How can i use this value outside the function?
You can initialize a variable at the top level and assign it inside the function
let foo
function bar() {
foo = "1"
}
bar()
console.log(foo)