View Source
Improve this doc
getCssProperty
Get a css property from a DOM-element selected by given selector. The return value
is formatted to be testable. Colors gets parsed via rgb2hex
and all other properties get parsed via css-value.
Note that shorthand CSS properties (e.g. background, font, border, margin, padding, list-style, outline,
pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access
the longhand properties (e.g. background-color) to access the desired values.
Usage
1
| browser.getCssProperty(selector,cssProperty);
|
Parameters
Param |
Type |
Details |
selector |
String |
element with requested style attribute |
cssProperty |
String |
css property name |
Example
example.html1
| <label id="myLabel" for="input" style="color: #0088cc; font-family: helvetica, arial, freesans, clean, sans-serif, width: 100px">Some Label</label>
|
getCssProperty.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| it('should demonstrate the getCssProperty command', function () { var elem = $('#myLabel')
var color = elem.getCssProperty('color') console.log(color)
var font = elem.getCssProperty('font-family') console.log(font)
var width = elem.getCssProperty('width') console.log(width) })
|
Uses