0

I want to get the background color of an element in a DOM using protractor so I'm doing the following.

var redArc = AESummaryTile.performanceChart.element(by.id('myElement')).getCssValue("background-color");

the problem with this is that it returns an rgba, not an rgb which is what I want. The css file only contains the hex value of the color for this element and when examining the page I only see an rgb value. Is there a reason why protractor returns an rgba instead of rgb.

I found the following references on converting the values but I would like to know if there is a better way to do this using protactor

javascript - RGB to Hex and Hex to RGB how to get Hex value instead of RGB

Any help on this would be appreciated

Community
  • 1
  • 1
polaris
  • 47
  • 1
  • 2
  • 10

1 Answers1

1

Since the colors are fixed, why not use rgba instead of converting it to hex in your code?

Example:

var bgColorDeleted = 'rgba(238, 120, 131, 1)'; //Red
var bgColorNormalWhite = 'rgba(255, 255, 255, 1)'; //White

tempObject.elmRow.getCssValue('background-color').then(function(bgColor) {
    expect(bgColor).toBe(bgColorNormalWhite);
}); 

//When marked (to be deleted) it becomes red

tempObject.elmRow.getCssValue('background-color').then(function(bgColor) {
    expect(bgColor).toBe(bgColorDeleted );
}); 
Paul Co
  • 447
  • 2
  • 9