|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectgeb.navigator.Navigator
abstract class Navigator extends Object
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/
Property Summary | |
---|---|
Browser |
browser
|
Constructor Summary | |
Navigator(Browser browser)
|
Method Summary | |
---|---|
Navigator
|
add(String selector)
|
Navigator
|
add(WebElement[] elements)
|
Navigator
|
add(Collection elements)
|
Collection
|
allElements()
Returns all context elements. |
boolean
|
asBoolean()
|
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. |
void
|
click()
Clicks on the first context element. |
void
|
click(Class pageClass)
|
void
|
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(String selector)
Creates a new Navigator instance containing the elements matching the given CSS selector. |
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. |
protected WebElement
|
getElement(int index)
Gets the element at the given index. |
protected List
|
getElements(Range range)
Gets the elements in the given range. |
protected List
|
getElements(Collection indexes)
Gets the elements at the given indexes. |
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. |
static Navigator
|
on(Browser browser, WebElement[] contextElements)
Factory method to create an initial Navigator instance. |
static Navigator
|
on(Browser browser, Navigator[] navigators)
Factory method to create a Navigator instance that is composed of other instances. |
static Navigator
|
on(Browser browser, Collection contextElements)
Factory method to create an initial Navigator instance. |
static Navigator
|
on(Browser browser)
Factory method to create an initial Navigator instance. |
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()
|
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. |
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 class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Property Detail |
---|
final Browser browser
Constructor Detail |
---|
Navigator(Browser browser)
Method Detail |
---|
Navigator add(String selector)
Navigator add(WebElement[] elements)
Navigator add(Collection elements)
Collection allElements()
boolean asBoolean()
String attr(String name)
name
- name of the attribute
Navigator children()
Navigator children(String selector)
List classes()
void click()
void click(Class pageClass)
void 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(String selector)
Examples:
selector
- a CSS selector
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
protected WebElement getElement(int index)
index
- index of the element to retrieve - pass a negative value to start from the back
protected List getElements(Range range)
range
- range of the elements to retrieve
protected List getElements(Collection indexes)
indexes
- indexes of the elements to retrieve
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
static Navigator on(Browser browser, WebElement[] contextElements)
Hides the fact that there are two implementations of Navigator at work behind the scenes: one for working with an empty context that keeps the code for the other one, with most of the logic, simple.
browser
- the browser the content is attached tocontextElements
- the context elements to use
static Navigator on(Browser browser, Navigator[] navigators)
browser
- the browser the content is attached tonavigators
- the navigators to compose of
static Navigator on(Browser browser, Collection contextElements)
Hides the fact that there are two implementations of Navigator at work behind the scenes: one for working with an empty context that keeps the code for the other one, with most of the logic, simple.
browser
- the browser the content is attached tocontextElements
- the context elements to use
static Navigator on(Browser browser)
Hides the fact that there are two implementations of Navigator at work behind the scenes: one for working with an empty context that keeps the code for the other one, with most of the logic, simple.
browser
- the browser for which to create a navigator of it's entire content
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()
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-core 0.6.3 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org