@Hello Nisha, you can discover the color of a web element and then verify it by using getCssValue() method, which take CSS attribute as input and return value of that attribute like color, font-size etc. Below is a sample code for verifying the color of a web element:
public void GoogleAbout() throws Exception{
String color = driver.findElement(By.xpath("//a[@href='products/']")).getCssValue("color");
String[] hexValue = color.replace("rgba(", "").replace(")", "").split(",");
int hexValue1=Integer.parseInt(hexValue[0]);
hexValue[1] = hexValue[1].trim();
int hexValue2=Integer.parseInt(hexValue[1]);
hexValue[2] = hexValue[2].trim();
int hexValue3=Integer.parseInt(hexValue[2]);
String actualColor = String.format("#%02x%02x%02x", hexValue1, hexValue2, hexValue3);
Assert.assertEquals("#245dc1", actualColor);
}
Hope it helps!
Check out the Selenium Online Course to learn more about Webdriver.