Rico Strydom Rico Strydom - 8 days ago 5
CSS Question

content: "\f068" seen as "?"

I want to trieve the value of content in my pseude element.

script = "return window.getComputedStyle(document.querySelector('small.fa.text-muted.fa-minus'),':before').getPropertyValue('content');";
js = (JavascriptExecutor) webdriver;
content = js.executeScript(script);
System.out.println("content : " + content);


Css

.fa-minus:before {
content: "\f068";
}


For some reason my code doesn't return "\f068" but returns "?" instead. Why is that and what do I need to do to return "\f068"?

Debuging:

enter image description here

Answer

Well here's how you could do it with javascript

var el = document.querySelector('.test.fa-minus'),
pseudoEl = window.getComputedStyle(el,'::after'),
content = pseudoEl.getPropertyValue("content"),
characterValue = '\\' + content.charCodeAt(1).toString(16);

console.log(characterValue);

I honestly don't know how much java and javascript are different from each other, so this is just my two cents :D

fiddle