|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD | |||||||
interface Navigator extends Iterable
Navigator is a jQuery-style DOM traversal tool that wraps a set of WebDriver WebElements. The code is based on the Doj library written by Kevin Wetzels: http://code.google.com/p/hue/
| Method Summary | |
|---|---|
Navigator
|
add(String selector)
|
Navigator
|
add(WebElement[] elements)
|
Navigator
|
add(Collection elements)
|
Collection
|
allElements()
Returns all context elements. |
String
|
attr(String name)
Returns the value of the given attribute of the first context element. |
Navigator
|
children()
|
Navigator
|
children(String selector)
|
List
|
classes()
Returns the class names present on all elements. |
Navigator
|
click()
Clicks on the first context element. |
Navigator
|
click(Class pageClass)
|
Navigator
|
click(List potentialPageClasses)
|
Navigator
|
closest(String selector)
Creates a new Navigator instance containing the first ancestor element of each of the current context elements that match the selector. |
Navigator
|
eq(int index)
Gets the wrapped element at the given index. |
Navigator
|
filter(String selector)
Filters the set of elements represented by this Navigator to include only those that match the selector. |
Navigator
|
filter(Map predicates)
|
Navigator
|
filter(Map predicates, String selector)
|
Navigator
|
find(Map predicates, String selector, Range range)
Creates a new Navigator instance containing the elements matching the given CSS selector. |
Navigator
|
find(Map predicates, String selector, Integer index)
Shorthand for |
Navigator
|
find(Map predicates, Integer index)
Shorthand for |
Navigator
|
find(String selector)
Shorthand for |
Navigator
|
find(String selector, int index)
Shorthand for |
Navigator
|
find(Map predicates)
Creates a new Navigator instance containing the elements whose attributes match the specified values or patterns. |
Navigator
|
find(Map predicates, String selector)
Selects elements by both CSS selector and attributes. |
Navigator
|
findAll(Closure predicate)
Overrides the standard Groovy findAll so that the object returned is a Navigator rather than a Collection |
Navigator
|
first()
Creates a new Navigator instance containing only the first context element (wrapped). |
WebElement
|
firstElement()
Returns the first context element (not wrapped). |
Navigator
|
getAt(int index)
Gets the wrapped element at the given index. |
Navigator
|
getAt(Range range)
Gets the wrapped elements in the given range. |
Navigator
|
getAt(Collection indexes)
Gets the wrapped elements at the given indexes. |
String
|
getAttribute(String name)
Returns the value of the given attribute of the first context element. |
int
|
getHeight()
Returns the height of the first element the navigator matches or 0 if it matches nothing. |
JQueryAdapter
|
getJquery()
Returns an adapter for calling jQuery methods on the elements in this navigator. |
int
|
getWidth()
Returns the width of the first element the navigator matches or 0 if it matches nothing. |
int
|
getX()
Returns the x coordinate (from the top left corner) of the first element the navigator matches or 0 if it matches nothing. |
int
|
getY()
Returns the y coordinate (from the top left corner) of the first element the navigator matches or 0 if it matches nothing. |
Navigator
|
has(String selector)
Filters the set of elements represented by this Navigator to include only that have one or more descendants that match the selector. |
boolean
|
hasClass(String className)
Returns true if at least one of the context elements has the given class. |
Navigator
|
head()
Creates a new Navigator instance containing only the first context element (wrapped). |
boolean
|
is(String tag)
Returns true if at least one of the context elements matches the tag. |
boolean
|
isDisabled()
Shorthand for |
boolean
|
isDisplayed()
Uses the isDisplayed() of RenderedWebElement to determine if the first element in the context is displayed. |
boolean
|
isEmpty()
Returns true when there are no context elements. |
boolean
|
isReadOnly()
Shorthand for |
Iterator
|
iterator()
|
Navigator
|
last()
Creates a new Navigator instance containing only the last context element (wrapped). |
WebElement
|
lastElement()
Returns the last context element (not wrapped). |
Navigator
|
leftShift(def value)
|
Navigator
|
next()
Creates a new Navigator instance containing the next sibling elements of the current context elements. |
Navigator
|
next(String selector)
Creates a new Navigator instance containing the next sibling elements of the current context elements, matching the selector. |
Navigator
|
nextAll()
Creates a new Navigator instance containing all following sibling elements of the current context elements. |
Navigator
|
nextAll(String selector)
Creates a new Navigator instance containing all following sibling elements of the current context elements that match the selector. |
Navigator
|
nextUntil(String selector)
Creates a new Navigator instance containing all following sibling elements of the current context elements up to, but not including, the first to match the selector. |
Navigator
|
not(String selector)
Returns a new Navigator instance containing all elements of the current Navigator that do not match the selector. |
Navigator
|
parent()
Creates a new Navigator instance containing the direct parent elements of the current context elements. |
Navigator
|
parent(String selector)
Creates a new Navigator instance containing the direct parent elements of the current context elements that match the selector. |
Navigator
|
parents()
Creates a new Navigator instance containing all the ancestor elements of the current context elements. |
Navigator
|
parents(String selector)
Creates a new Navigator instance containing all the ancestor elements of the current context elements that match the selector. |
Navigator
|
parentsUntil(String selector)
Creates a new Navigator instance containing all the ancestor elements of the current context elements up to but not including the first that matches the selector. |
Navigator
|
plus(Navigator navigator)
Merges the Navigator instance with the current instance to create a new Navigator instance containing the context elements of both. |
Navigator
|
prevAll()
Creates a new Navigator instance containing all preceding sibling elements of the current context elements. |
Navigator
|
prevAll(String selector)
Creates a new Navigator instance containing all preceding sibling elements of the current context elements, matching the selector. |
Navigator
|
prevUntil(String selector)
Creates a new Navigator instance containing all preceding sibling elements of the current context elements up to, but not including the first matching the selector. |
Navigator
|
previous()
Creates a new Navigator instance containing the previous sibling elements of the current context elements. |
Navigator
|
previous(String selector)
Creates a new Navigator instance containing the previous sibling elements of the current context elements, matching the selector. |
Navigator
|
remove(int index)
Creates a new Navigator instance by removing the element at the given index from the context. |
Navigator
|
siblings()
Selects the @return |
Navigator
|
siblings(String selector)
|
int
|
size()
Returns the number of context elements. |
String
|
tag()
Returns the tag name of the first context element. |
Navigator
|
tail()
Creates a new Navigator instance containing all but the first context element (wrapped). |
String
|
text()
Returns the text content of the first context element. |
Navigator
|
unique()
Creates a new Navigator instance containing all elements of this instance with duplicate elements removed |
def
|
value()
Returns the value of the first context element for input elements (including textarea, select and button). |
Navigator
|
value(def value)
Sets the value of the form input elements to the given value. |
Navigator
|
verifyNotEmpty()
Throws an exception when the Navigator instance is empty. |
| Methods inherited from interface Iterable | |
|---|---|
| iterator |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Method Detail |
|---|
Navigator add(String selector)
Navigator add(WebElement[] elements)
Navigator add(Collection elements)
Collection allElements()
String attr(String name)
name - name of the attribute
Navigator children()
Navigator children(String selector)
List classes()
Navigator click()
Navigator click(Class pageClass)
Navigator click(List potentialPageClasses)
Navigator closest(String selector)
Unlike parent(), this method will keep traversing up the DOM until a match is found or the top of the DOM has been found
selector - to match
Navigator eq(int index)
When no such element exists, an empty Navigator instance is returned.
index - index of the element to retrieve - pass a negative value to start from the back
Navigator filter(String selector)
selector - a CSS selector
Navigator filter(Map predicates)
Navigator filter(Map predicates, String selector)
Navigator find(Map predicates, String selector, Range range)
Examples:
selector - a CSS selector
Navigator find(Map predicates, String selector, Integer index)
find(predicates, selector, index..index)
Navigator find(Map predicates, Integer index)
find(predicates, null, index..index)
Navigator find(String selector)
find(null, selector, null)
Navigator find(String selector, int index)
find(selector)[indexOfElement].
selector - a CSS selectorindex - index of the required element in the selection
Navigator find(Map predicates)
Examples:
predicates - a Map with keys representing attributes and values representing required values or patterns
Navigator find(Map predicates, String selector)
selector - a CSS selectorpredicates - a Map with keys representing attributes and values representing required values or patterns
Navigator findAll(Closure predicate)
Navigator first()
WebElement firstElement()
Navigator getAt(int index)
When no such element exists, an empty Navigator instance is returned.
index - index of the element to retrieve - pass a negative value to start from the back
Navigator getAt(Range range)
When no such elements exist, an empty Navigator instance is returned.
range - range of the elements to retrieve
Navigator getAt(Collection indexes)
When no such elements exist, an empty Navigator instance is returned.
indexes - indexes of the elements to retrieve
String getAttribute(String name)
name - name of the attribute
int getHeight()
To get the height of all matched elements you can use the spread operator navigator*.height
JQueryAdapter getJquery()
int getWidth()
To get the width of all matched elements you can use the spread operator navigator*.width
int getX()
To get the x coordinate of all matched elements you can use the spread operator navigator*.x
int getY()
To get the y coordinate of all matched elements you can use the spread operator navigator*.y
Navigator has(String selector)
selector - a CSS selector
boolean hasClass(String className)
className - class to check for
Navigator head()
boolean is(String tag)
tag - tag to match
boolean isDisabled()
hasAttribute("disabled").
boolean isDisplayed()
boolean isEmpty()
boolean isReadOnly()
hasAttribute("readonly").
Iterator iterator()
Navigator last()
WebElement lastElement()
Navigator leftShift(def value)
Navigator next()
Navigator next(String selector)
Unlike next(), this method will keep looking for the first matching sibling until it finds a match or is out of siblings.
selector - to match
Navigator nextAll()
Navigator nextAll(String selector)
Unlike next(), this method will keep looking for the first matching sibling until it finds a match or is out of siblings.
selector - to match
Navigator nextUntil(String selector)
selector - to match
Navigator not(String selector)
selector - a CSS selector
Navigator parent()
Navigator parent(String selector)
selector - to match
Navigator parents()
Navigator parents(String selector)
selector - to match
Navigator parentsUntil(String selector)
selector - to match
Navigator plus(Navigator navigator)
navigator - navigator to merge with this one
Navigator prevAll()
Navigator prevAll(String selector)
selector - to match
Navigator prevUntil(String selector)
selector - to match
Navigator previous()
Navigator previous(String selector)
Unlike previous(), this method will keep looking for the first matching sibling until it finds a match or is out of siblings.
selector - to match
Navigator remove(int index)
If no such element exists, the current instance is returned.
index - index of the element to remove - pass a negative value to start from the back
Navigator siblings()
Navigator siblings(String selector)
int size()
String tag()
Navigator tail()
String text()
Navigator unique()
def value()
In the case of a select, the value of the first selected option is returned.
Navigator value(def value)
value - value to use
Navigator verifyNotEmpty()
Groovy API Documentation for Geb 0.9.0-RC-3 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org