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

HenriqueUrbano

21-06-2019

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?

Accepted Solutions (1)

Accepted Solutions (1)

HenriqueUrbano

24-06-2019

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().)

Answers (0)