Expand my Community achievements bar.

SOLVED

Is AEM/Hobbes.Js able to automaticaly check for the value of a CSS atribute?

Avatar

Former Community Member

I'm trying to automate a few tests with AEM/Hobbes.JS and one of the tasks is to make sure that the color of the texts are correct. For this, I would have to check the value of the "Color" attribute of the CSS that's applied to the text. However, from what I've seen in the documentation, the css classes that Hobbes.js has only check if the DOM attribute has the desired CSS class, not if the values inside the CSS are correct. I've also tried to execute a custom function to reach the CSS through the execFct()  method, but the custom JS code didn't work on it (Even though the code was correct, and worked if I tested it on Chrome's console). Is there any way for Hobbes.js / AEM to check for values inside the page's CSS, or is that not supported?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

For those who end up having the same problem, me and my coworker came up with a solution: by using de execFct() method, one can run custom Javascript code that reaches the attribute value of a CSS file using the getComputedStyle() and getPropertyValue() methods (as long as the hobs.context() function is used before the Javascript function. e.g. document.getElementById becomes hobs.context().document.getElementById().)

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

For those who end up having the same problem, me and my coworker came up with a solution: by using de execFct() method, one can run custom Javascript code that reaches the attribute value of a CSS file using the getComputedStyle() and getPropertyValue() methods (as long as the hobs.context() function is used before the Javascript function. e.g. document.getElementById becomes hobs.context().document.getElementById().)

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----