Rico Strydom Rico Strydom - 1 year ago 96
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);


.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"?


enter image description here

Answer Source

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);


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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download