I'm new to Nightwatch.js.
I was wondering how I can store the result of the getText command into a variable to be used outside of the command.
This is my code now:
var endDate;
client.getText("span.date", function(result){
LOGGER(`INSIDE FXN ${result.value}`);
endDate = result.value;
});
LOGGER(`OUTSIDE FXN ${endDate}`);
Results:
*******INSIDE FXN 3/30/2018*******
*******OUTSIDE FXN UNDEFINED*******
As you can see, I'm trying to get the text in span.date and displaying it with LOGGER (which works successfully inside the function). Once we move outside of the callback function of getText, when I display it with LOGGER, it outputs undefined.
It's really important that the date is store in a variable because I intend to use it in a test element (for a UI Smoke test).
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire