I want to check the color of an element in an html page. The color of this element is set with a javascript, look at the image
The element with div-id \"Ab_banco_M
try this, worked perfect for me:
import org.openqa.selenium.support.Color;
String color = driver.findElement(By.xpath("xpath_value")).getCssValue("color");
System.out.println(color);
String hex = Color.fromString(color).asHex();
System.out.println(hex);
So you can get color using getCssValue("color");
and getCssValue("background-color");
.
However, that would be in RGB, so you need to convert to hex. With hex code you can then compare the value and print it out so that you can see what you are getting after each getCssValue
.