问题
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
?
回答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
回答2:
you can convert the decimal value (0 - 255) to hex (0 - FF)
var hexString = redNumber.toString(16) + greenNumber.toString(16) + blueNumber.toString(16);
来源:https://stackoverflow.com/questions/10699039/how-to-convert-color-from-rrr-ggg-bbb-to-rrggbb-by-javascript