# Check for color

**URL:** <https://www.ruby-forum.com/t/check-for-color/152416>\
**Category:** Rails\
**Created:** [November 3, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/check-for-color/152416 "2008-11-03T19:19:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 3, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/1 "2008-11-03T19:19:28Z")

</div>

Does anyone know how to check to make sure that the text on a screen is  
a certain color.

What I wish to do is check to make sure that the text color is red.

Any ideas??

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 3, 2008, 8:13pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/2 "2008-11-03T20:13:12Z")

</div>

Can you give us more information about the goal? I’d think you could  
do a visual check of the page, or do some direct styling.

I haven’t tried, but perhaps you can walk the DOM and check for  
styling?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 3, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/3 "2008-11-03T20:16:29Z")

</div>

I am trying to create an auto test that will check some values on a page  
and then also make sure that the text on some of the entries is in red  
and other text in black. The text on the page will always be different  
so I don’t think checking all the HTML is the way to go.

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 3, 2008, 10:48pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/4 "2008-11-03T22:48:12Z")

</div>

I guess my next question would be:

Are you generating this page yourself or are you reading a page from  
somewhere else?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 4, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/5 "2008-11-04T17:06:14Z")

</div>

On Mon, Nov 3, 2008 at 11:16 AM, Bob S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to create an auto test that will check some values on a page  
> and then also make sure that the text on some of the entries is in red  
> and other text in black.

Text is just character strings – it doesn’t have “colors” 🙂

A User Agent /may/ display text with colors provided through style  
sheets or style attributes in tags.

If you know in advance how the styling will be applied you might be  
able to use WebTest; otherwise I’d suggest looking at a UA-based  
tool like Selenium.

## HTH!

Hassan S. ------------------------ removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 4, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/check-for-color/152416/6 "2008-11-04T14:07:29Z")

</div>

This page is from an internal website for my company, so no I am not  
generating it myself.
