Styles of a CSS Class

4 posts, 0 answers
  1. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 24 Feb 2014 Link to this post

    Hello,

    I have a DIV element that I want to get the background color of.

    The background is not listed in the DIV's styles attribute, but it's instead a part of a CSS class the DIV is using.

    <div class="wrapper" style="height: 30px;">
    </div>

    the wrapper.css is as follows:
    .wrapper { background: #f2dcdb; }

    I can't seem to find a way to look into the background attribute of the wrapper class. I can't seem to find a way.

    Any help would be appreciated.

    Thank you
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 28 Feb 2014 Link to this post

    Hi Matt,

    Thank you for contacting us.

    It doesn't matter whether it is an external css or not. In both cases you can use this code to get the style:

    Log.WriteLine(myDiv.GetComputedStyleValue("backgroundColor").ToString());

    This will write the value into the log.

    Let me know if this helps.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 28 Feb 2014 Link to this post

    Thanks Boyan,

    That's what I was missing, the "backgroundColor" as I was using "background".
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1045 posts

    Posted 28 Feb 2014 Link to this post

    Hi Matt,

    Glad to hear that.

    Let us know if you need additional assistance.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top