Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
1.9k views
by The go-to Tester (324 points)
retagged by
Is it possible to handle colors in web driver? Explain
closed with the note: got it.
by The go-to Tester (181 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

0 like 0 dislike
by The go-to Tester (181 points)

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.
 

 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...