How can I get the HTML style value?

@kazurayam There’s no great mystery here. The HTML <html> element supports Global attributes; style is a global attribute.

Here is this forum page:

@ashraf.madina You can use this JavaScript to access the style attribute object and retrieve its properties using its getPropertyValue() method:

document.querySelector("html").getPropertyValue("--header-offset");

And in Groovy:

String js = 'return document.querySelector("html").getPropertyValue("--header-offset");'
String value = WebUI.executeJavaScript(js, null);

Beware, you may get a result in rgb(...) format. If that happens, you may need to convert it to hexadecimal. In actuality, it doesn’t matter – if the value is correct, go with it.


EDIT: fixed the js to have a return statement.

1 Like