用量角器获取伪元素的值

bod*_*ine 2 javascript angularjs angularjs-e2e protractor e2e-testing

我想验证伪元素的文本内容.承诺从使用中返回ptor.executeScript("window.getComputedStyle(jQuery('.my-class')[0], ':after').content").then(function(data){ console.log(arguments) // {'0':null} });

我也试过在预期中放弃它,但我猜这是因为同样的原因失败了.

既然CSS声明指向了元素的一个属性,我应该尝试读取该属性吗?

Jmr*_*Jmr 9

executeScript 将等待您返回一个值 - 所以您需要这样做:

ptor.executeScript("return window.getComputedStyle(jQuery('.my-class')[0], ':after').content")
    .then(function(data){ console.log(arguments)});
Run Code Online (Sandbox Code Playgroud)