power_settings_new

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

by (324 points)
+1 vote
324 views
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.

 

E.g.

        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.
 

 

add
...