bodine bodine - 2 years ago 84
AngularJS Question

getting the value of a pseudo-element with protractor

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.

Since the CSS Declaration for this is pointing at one of the element's attributes anyway, should I just try to read that attribute?

Jmr Jmr
Answer Source

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)});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download