After locating my element in Selenium, I've come across an interesting challenge.
IWebElement icon = box.FindElement(By.ClassName("box-icon"));
Sometimes, this element (icon) has a content set as follows:
&:after {
content: $icon-special;
}
My goal is to verify if the content
property currently equals $icon-special
. To achieve this, I understand that I need to run a JavaScript script using JSDriver
and provide my IWebElement icon
as an argument. However, I'm unsure how to extract the value of after.content:
using JavaScript/jQuery.
This is what I've come up with:
var script = @"return window.getComputedStyle(arguments[0], ':after').getPropertyValue('content');";
var result = JSDriver.Execute(script, icon );
Unfortunately, the result consists of strange characters like hearts and dots;
It's important to note that I cannot make any modifications to the DOM during testing.