Forum Discussion

jerkins's avatar
jerkins
Occasional Contributor
5 years ago
Solved

Capturing Pseudo Elements

Hi Team,

Is there a way to capture Pseudo elements using TestComplete?

I have '::after' in my code and I have to capture it to read the Computed Style of it. Now, how do I capture ::after ?

  • jerkins's avatar
    jerkins
    5 years ago

    Hi Tanya,

    Thanks for the reply. I figured out the solution myself which is pasted below.

    //object is the node inside which pseudo element is available

     

    var window = object.ownerDocument.defaultView;

    var style = window.getComputedStyle(object,":after");

    var computedStyle = style["content"];

     

3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi jerkins,

     

    Could you please give us more information? Images or some info about what you have inside :after will help.

    • jerkins's avatar
      jerkins
      Occasional Contributor

      Hi Tanya,

      Thanks for the reply. I figured out the solution myself which is pasted below.

      //object is the node inside which pseudo element is available

       

      var window = object.ownerDocument.defaultView;

      var style = window.getComputedStyle(object,":after");

      var computedStyle = style["content"];

       

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi jerkins,

        I'm happy to hear this!

        Thanks for sharing the solution with us. Good luck in testing :)