Gets the value of a CSS property of this element.

Namespace: OpenQA.Selenium
Assembly: WebDriver (in WebDriver.dll) Version: 2.21.0.0 (2.21.0.0)

Syntax

C#
string GetCssValue(
	string propertyName
)
Visual Basic
Function GetCssValue ( _
	propertyName As String _
) As String
Visual C++
String^ GetCssValue(
	String^ propertyName
)

Parameters

propertyName
Type: System..::..String
The name of the CSS property to get the value of.

Return Value

The value of the specified CSS property.

Remarks

The value returned by the GetCssValue(String) method is likely to be unpredictable in a cross-browser environment. Color values should be returned as hex strings. For example, a "background-color" property set as "green" in the HTML source, will return "#008000" for its value.

Exceptions

ExceptionCondition
OpenQA.Selenium..::..StaleElementReferenceExceptionThrown when the target element is no longer valid in the document DOM.

See Also