1

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

it's returns me color in (rrr, ggg, bbb), how can i get this color in RRGGBB?

Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
user1211063
  • 127
  • 1
  • 3
  • 11

2 Answers2

3

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
Aleh Douhi
  • 1,958
  • 1
  • 14
  • 13
1

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

var hexString = redNumber.toString(16) + greenNumber.toString(16) + blueNumber.toString(16);
Jhong
  • 2,714
  • 22
  • 19