I was looking through testing CSS styles... I tried this in my chrome console:
var el = document.querySelector(".create-body h2[class='title']");
let compStyles = window.getComputedStyle(el);
compStyles.getPropertyValue('font-weight');
OUTPUT: -> "900"
What I want is to validate this kind of output in my Test Cases.
this basically prints the CSS style easily, like I'm doing the testing with TestCafe I was using ClientFunction() but not able to get the right way.
We know that TestCafe does have a function called: getStyleProperty but I was reading and in certain points, the Style might not work and I should use getComputedStyle instead.
I have transcripted the code to this on JS but does not work:
async getPseudoElementFunction() {
const html = ClientFunction(() => document.querySelector('.create-body h2[class="title"]'));
const fontFamily = ClientFunction(async () => window.getComputedStyle(await html()).getPropertyValue('font-size'));
return fontFamily;
}
If I call that function, I am not even able to do an "expect" testcafe validation because it needs to be parsed firstly: