Search code examples
pythonselenium-webdriversafari

How to verify color of a web element in Selenium WebDriver?


I am looking to identify the text colour of a particular class within a div (ie. Red or green) is there any way to use WebDriver to do this ? I have found alternatives that use openqa.selenium.WebDriver; and subsequently .getcssvalue. Would it be possible to use .getattribute ?

Pls help stuck for days now


Solution

  • If you are using Python's selenium webdriver this should suffice: .value_of_css_property(property_name) Where property name would be 'color' I believe. Docs can be found here