Sunday 21 May 2017

How can I access a variable inside a .then function which is inside another .then function?

Here I'm trying to Log value of a to console.

driver.sleep(2000).then(function logAInConsole(){
var a = ["Quas","Wex","Exort","Invoke"];
    for(var i = 0; i < a.length; i++){
        driver.sleep(1000).then(function loggingA(){
        driver.sleep(1000).then(function(){
        console.log(a[i]);})
        });
    }
});

Result of given code is:
Undefined
Undefined
Undefined
Undefined



via Pawan Juyal

No comments:

Post a Comment