This is a migrated thread and some comments may be shown as answers.

Styles of a CSS Class

3 Answers 31 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 24 Feb 2014, 06:29 PM
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

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 28 Feb 2014, 10:55 AM
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
0
Matt
Top achievements
Rank 1
answered on 28 Feb 2014, 03:57 PM
Thanks Boyan,

That's what I was missing, the "backgroundColor" as I was using "background".
0
Boyan Boev
Telerik team
answered on 28 Feb 2014, 05:32 PM
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
Tags
General Discussions
Asked by
Matt
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Matt
Top achievements
Rank 1
Share this question
or