When trying getCssValue("color"), it still returns the rgb value not the hex value.

2,073 views
Skip to first unread message

Lihua Zhang

unread,
Apr 10, 2012, 4:18:10 AM4/10/12
to webdriver
Hi All,

When trying getCssValue("color"), it still returns the rgb value not
the hex value.
I search the Google and find some explanation in
https://groups.google.com/forum/?fromgroups#!topic/selenium-developers/gBqWHo068NY
but no solution.
Should I involve an enum class for converting rbg to hex?

Thanks

Luke Inman-Semerau

unread,
Apr 10, 2012, 10:52:15 AM4/10/12
to webd...@googlegroups.com
There is a Color class included with selenium java to help with the conversion. Check it out:

http://code.google.com/p/selenium/source/browse/trunk/java/client/src/org/openqa/selenium/support/Color.java

-Luke

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>

Moises Siles

unread,
Apr 11, 2012, 10:07:00 AM4/11/12
to webd...@googlegroups.com
Do we have something similar for C#, or what should be the workaround?

Thanks

Nat Img

unread,
Sep 22, 2013, 1:09:25 AM9/22/13
to webd...@googlegroups.com
Hi there. I am totally lost on this same issue.. I have one single website that is behaving this way in chrome. The actual CSS is in HEX, but the chrome inspector keep showing it in RGB, but when altered, the changes to not take effect and revert to the RGB, which is just incorrect. IF anyone can help, I would greatly appreciate it. 

David

unread,
Sep 23, 2013, 6:48:07 PM9/23/13
to webd...@googlegroups.com
moises,

you can just do online search for RGB to hex (followed with language of choice) for options. For example, this is what I came across for .NET:


same idea to find solution for the reverse translation

David

unread,
Sep 23, 2013, 6:50:33 PM9/23/13
to webd...@googlegroups.com
Nat,

How did you alter the values? Within Chrome inspector (or the HTML source/DOM editor)? Or within Chrome javascript console? Or from Selenium? If from Chrome inspector, trying doing it with the javascript console (using the appropriate object like document.something or the jQuery equivalent, etc.). You can also try fetching the value from javascript console via the appropriate js object rather than the inspector to see if that reports a different value.
Reply all
Reply to author
Forward
0 new messages