Trying to get Hex/RGB value of a color preview swatch, please help!
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Trying to get Hex/RGB value of a color preview swatch, please help!
Hi everyone
In configuration page some colors are customizable.
- When clicked on any of the input fields, a color chooser pops up.
- Selecting a color populates the field with the hex value.
- The preview swatch updates to the selected color.
I am trying to access the hex value of the preview color. After some reading, this is what I came up with:
(I have noticed that swatch value shows up as Hex in Chrome but as RGB in IE!)
var colorPrimary = page.QuerySelector(".evo-colorind"); var style = page.contentDocument.defaultView.getComputedStyle(colorPrimary, ""); Log.Message(style.background-color);
I am getting JavaScript runtime error 0x80020101 at 'style' var. Any help deeply appreciated.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @royd,
Could you please mark the answer that help you as a solution? You see a big green "Accept as Solution" button next to it. It will help other community members who will face a similar situation. Thanks.
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While I was searching for something else I happened upon something and thought it might be of assistance to you. The smartbear support for handling browser differences has a secion about attribute values that looks specifically at how to handle the background color in different browsers as an example
-------------------------------------------------
Standard syntax disclaimers apply
Regards,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rudolph
Thanks for the link. This will help me understand what I am doing wrong.
Thanks. 🙂
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad it could help
What stood out to me is that it appears the style they are picking up is "backgroundColor" rather than "background-color"
-------------------------------------------------
Standard syntax disclaimers apply
Regards,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tanya
I always do, when I have found a solution!
I would like to take the opportunity to point out, that the users are always there to help, more than support people. Especially Robert has always been there and help solve 95% of my problems!! I can not thank him and all other experts that have helped me.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Robert
Sorry for delayed response. It took me a while but finally figured it out. Thanks for pointing me to right direction. This is what finally worked:
var previewColor = previewSwatch.ownerDocument.defaultView.getComputedStyle(previewSwatch, "").backgroundColor;
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @royd.
I'm so glad to hear that the solution has been found 🙂
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
color_value=Aliases.browser.page.{object_name}.getAttribute('fill')
Log.Message(color_value)
color_value has "#e1542b", I have to convert hexcode to rgb inorder to verify rgb color value, as have a color file where I stored the list of colour name according to rgb values.
Kindly help on this.

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »