Skip to content Skip to sidebar Skip to footer

How To Convert Color From (rrr Ggg Bbb) To RRGGBB By Javascript

I have this code (in Selenium IDE): storeEval | window.document.defaultView.getComputedStyle(window.document.getElementsByTagName('input')[0]).getPropertyValue('background-color')

Solution 1:

Try this:

command: storeEval
target : color = window.document.defaultView.getComputedStyle(window.document.getElementsByTagName('input')[0]).getPropertyValue('background-color'); colorArr = color.replace(/[(rgb()\)]/g, '').split(','); hexString = parseInt(colorArr[0]).toString(16) + parseInt(colorArr[1]).toString(16) + parseInt(colorArr[2]).toString(16);
value  : result

Solution 2:

you can convert the decimal value (0 - 255) to hex (0 - FF)

var hexString = redNumber.toString(16) + greenNumber.toString(16) + blueNumber.toString(16);

Post a Comment for "How To Convert Color From (rrr Ggg Bbb) To RRGGBB By Javascript"