I have a function .getText
from which I need to return a variable num3
to compare it on the following pages. But the assert at the end is failing because num3 is "undefined".
var num3;
...
.getText('my_selector', function(result) {
const num = (number * result.value) * 0.05;
const num2 = (number * result.value) - num;
num3 = Math.round(num2 * 100) / 100;
this.expect.element('my_selector').to.have.value.equal(num3); })
...
.assert.containsText('my_selector2', num3) //undefined