小编San*_*cks的帖子

量角器 - 如何在变量中存储browser.execute脚本的值?

我试图将browser.executeScript的值存储在我的块中的局部变量中但是在所有情况下我都无法将其显示为null.

到目前为止,我已尝试过很多方法

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

还有这个

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;
}
Run Code Online (Sandbox Code Playgroud)

我在我的规范中使用这个

   iit('', function() {        

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

            returnColor();


        });
Run Code Online (Sandbox Code Playgroud)

真的会告诉我有人可以告诉我如何正确地做到这一点吗?

javascript css testing angularjs protractor

4
推荐指数
1
解决办法
2598
查看次数

标签 统计

angularjs ×1

css ×1

javascript ×1

protractor ×1

testing ×1