how you can handle colors in web driver? [closed]

by (324 points)
+1 vote
Is it possible to handle colors in web driver? Explain
closed with the note: got it.
by (171 points)
Yes, it is possible to handle colors in WebDriver. Can you give one scenario where you are facing a problem? Or you want to start with it?

1 Answer

by (171 points)
0 votes

You can get color of an element by simply using getCssValue function.



        String Color = driver.findElement(By.xpath("//div[@class='gb_e gb_f gb_g gb_xb']/a")).getCssValue("color");
This will return you the string 
rgba(#,#,#) where # is your color value. Say your element color is Green it will return rgba(0,225,0)
You can then work with returned values.
Hope that helps.