Pages

Wednesday 7 March 2012

How can I read background-color of an element?

We can get/read the background-color of an element by using getCssValue() method of WebDriver:


driver.get("http://www.google.co.in/");
String color = driver.findElement(By.name("btnK")).getCssValue("background-color");

System.out.println("The background color of Google search button"+color);

No comments:

Post a Comment