mercredi 29 juin 2016

Protractor - How to store the value of browser.execute script in varriable?

I am trying to store the value of browser.executeScript inside a local variable in my it block but I am not able to do so in all the cases it displays null.

I have tried many ways so far

     browser.executeScript('$("#txtName").css("border-left-color");').then(function (color) {
        console.log("This is color" + color);
    });

Also this

function returnColor()
{
     var  a = browser.executeScript('$("#txtName").css("border-left-color");');
     return a;
}

function getColorCode()
{
       var a = returnColor().then(function(list){
           console.log("Output is ***************" + list);
             return list;
      });

        return a;
}

I am using this inside my spec as

   iit('', function() {        

             browser.executeScript('$("#txtName").css("border-left-color");').then(function (color) {
                console.log("This is color" + color);
            });

            returnColor();


        });

Will really appreaciate it someone can tell me how to do it properly?

Aucun commentaire:

Enregistrer un commentaire