GET CSS Values of Web-Element using Selenium WebDriver


GET CSS Values of Web-Element using Selenium WebDriver

There are certain situations in the project where we need to validate the background color, color or font of the particular web-element of our application.

For that purpose, we can use the getCSSValue of the web element.



For example, in the below scenario I am validating the Color, background color and the font size of google logo placed on their home page.

Output of above code execution is:


Here getCSSValue(“color”) and getCssValue("background-color") will always return value as RGBA (Red,Green,Blue and Amber) format.

All this color combinations can be checked using below link.



SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
June 17, 2020 at 9:02 PM

Thanks Ankur, this blog is very good ,attractive and clear text style .

Reply
avatar