CSS of the pseudo-element

Hello

in katalon, can I get the css value of a pseudo-element?

Hi Fabio

Not directly, no. The problem is, CSS pseudo-elements are not part of the DOM, therefore, DOM access methods can’t “see” them.

If you have the means to change how the pseudo-elements are applied, you could then use regular APIs to access them. For example, if your CSS applied a specific class as well as the pseudo (e.g. “div.my-class::after”) then you can infer the rest by reading the class.

div.my-class::after {
  content: "Something";
}

But, as you can see, that solution is messy and the code to deal with it and test it is likely to be even messier.

Russ

As Russ said, Selenium cannot locate pseudo elements. I tried for absolutely ages researching this, and it just can’t.
In my case, the pseudo element was a dropdown button attached to another button in order to present more options.
My workaround was moving to the button via the Actions.movetoWebElement(WebElement)
And then moving the cursor by a certain number of pixels to the right, and then clicking.

Again, it’s messy.
Good luck

Thanks :slight_smile: