Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How to verify color of a web element in Selenium Webdriver?

Category: Selenium WebDriver
// identify text
WebElement t = driver.findElement(By.tagName("h1"));
//obtain color in rgba
String s = t.getCssValue("color");
// convert rgba to hex
String c = Color.fromString(s).asHex();
System.out.println("Color is :" + s);
System.out.println("Hex code for color:" + c);

Leave a Reply

Your email address will not be published. Required fields are marked *