Skip to content

Commit

Permalink
Make examples in the section on css properties executable.
Browse files Browse the repository at this point in the history
  • Loading branch information
erdi committed Apr 19, 2015
1 parent 677adf4 commit a12ce83
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
20 changes: 12 additions & 8 deletions doc/new-manual/src/docs/asciidoc/030-navigator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,25 @@ Css properties of a navigator can be accessed using the `css()` method.

Consider the following HTML…

[source,html]
----
<div style="float: left">text</div>
include::{testDir}/navigator/CssPropertiesSpec.groovy[tag=html,indent=0]
----

You can obtain value of the `float` css property in the following way…
You can obtain the value of `float` css property in the following way…

[source,css]
----
$("div").css("float") == "left"
include::{testDir}/navigator/CssPropertiesSpec.groovy[tag=css,indent=0]
----

____
There are some limitations when it comes to retrieving css properties of `Navigator` objects. Color values should be returned as rgba strings, so, for example if the `background-color` property is set as `green` in the HTML source, the returned value will be `rgba(0, 255, 0, 1)`. Note that shorthand CSS properties (e.g. `background`, `font`, `border`, `border-top`, `margin`, `margin-top`, `padding`, `padding-top`, `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.
____
[WARNING]
====
There are some limitations when it comes to retrieving css properties of `Navigator` objects.
Color values should be returned as rgba strings, so, for example if the `background-color` property is set as `green` in the HTML source, the returned value will be `rgba(0, 255, 0, 1)`.
Note that shorthand CSS properties (e.g. `background`, `font`, `border`, `border-top`, `margin`, `margin-top`, `padding`, `padding-top`, `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.
====

== Sending keystrokes

Expand Down
37 changes: 37 additions & 0 deletions doc/new-manual/src/test/groovy/navigator/CssPropertiesSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package navigator

import geb.test.GebSpecWithCallbackServer

class CssPropertiesSpec extends GebSpecWithCallbackServer {

def "css properties"() {
given:
html """
<html>
// tag::html[]
<div style="float: left">text</div>
// end::html[]
</html>
"""

expect:
// tag::css[]
$("div").css("float") == "left"
// end::css[]
}
}

0 comments on commit a12ce83

Please sign in to comment.