问题描述
我想验证伪元素的文本内容.使用 ptor.executeScript("window.getComputedStyle(jQuery('.my-class')[0],':after').content")返回的承诺.console.log(arguments)//{'0':null}});
I'd like to verify the text content of a pseudo-element. The promise returned from using ptor.executeScript("window.getComputedStyle(jQuery('.my-class')[0], ':after').content").then(function(data){console.log(arguments) // {'0':null}});
我也曾尝试将其降为期望值,但我猜出于相同的原因而失败.
I've also tried dropping that in the expectation, but I'd guess that fails for the same reason.
由于CSS声明无论如何都指向该元素的属性之一,因此我应该尝试读取该属性吗?
Since the CSS Declaration for this is pointing at one of the element's attributes anyway, should I just try to read that attribute?
推荐答案
executeScript
将等待您返回值-因此您需要这样做:
executeScript
will waits for you to return a value - so you'll need to do:
ptor.executeScript("return window.getComputedStyle(jQuery('.my-class')[0], ':after').content")
.then(function(data){ console.log(arguments)});
这篇关于用量角器获取伪元素的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!