BasicElements
.eq(index)
Reduce the set of matched elements to the one at the specified index.
Parameter | Description |
---|---|
index | An integer indicating the 0-based position of the element. If negative, it will be counting backwards from the last element in the set. |
- returns: a new
Elements
that evaluates into a single element set with the element at the corresponding index, or an empty set if no element is found at that index
.first()
Reduce the set of matched elements to the first one. It's equivalent to
this.eq(0)
.
- returns: a new
Elements
that evaluates into a single element set with the first element, or an empty set ifthis
evaluates into an empty set
.last()
Reduce the set of matched elements to the last one. It's equivalent to
this.eq(-1)
.
- returns: a new
Elements
that evaluates into a single element set with the last element, or an empty set ifthis
evaluates into an empty set
.size()
Computes the size of the evaluated set.
- returns: size of the evaluated set
BasicWebElements
.add(selector)
Add elements to the set of matched elements.
Parameter | Description |
---|---|
selector | A string representing a selector expression to find additional elements to add to the set of matched elements. |
- returns: result of jQuery .add() method
- see: jQuery .add() method
.addBack()
Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
- returns: result of jQuery .addBack() method
- see: jQuery .addBack() method
.attr(attributeName)
Get the value of an attribute for the first element in the set of matched elements.
Parameter | Description |
---|---|
attributeName | The name of the attribute to get. |
- returns: result of jQuery .attr() method
- see: jQuery .attr() method
.children()
Get the children of each element in the set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .children() method
- see: jQuery .children() method
.closest(selector)
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
Parameter | Description |
---|---|
selector | A string containing a selector expression to match elements against. |
- returns: result of jQuery .closest() method
- see: jQuery .closest() method
.contents()
Get the children of each element in the set of matched elements, including text and comment nodes.
- returns: result of jQuery .contents() method
- see: jQuery .contents() method
.css(propertyName)
Get the value of style properties for the first element in the set of matched elements.
Parameter | Description |
---|---|
propertyName | A CSS property. |
- returns: result of jQuery .css() method
- see: jQuery .css() method
.data(key)
Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
Parameter | Description |
---|---|
key | Name of the data stored. |
- returns: result of jQuery .data() method
- see: jQuery .data() method
.end()
End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
- returns: result of jQuery .end() method
- see: jQuery .end() method
.filter(selector)
Reduce the set of matched elements to those that match the selector or pass the function's test.
Parameter | Description |
---|---|
selector | A string containing a selector expression to match the current set of elements against. |
- returns: result of jQuery .filter() method
- see: jQuery .filter() method
.find(selector)
.has(selector)
Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
Parameter | Description |
---|---|
selector | A string containing a selector expression to match elements against. |
- returns: result of jQuery .has() method
- see: jQuery .has() method
.hasClass(cssClass)
Determine whether any of the matched elements are assigned the given class.
Parameter | Description |
---|---|
cssClass | The class name to search for. |
- returns: result of jQuery .hasClass() method
- see: jQuery .hasClass() method
.html()
Get the HTML contents of the first element in the set of matched elements.
- returns: result of jQuery .html() method
- see: jQuery .html() method
.is(selector)
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
Parameter | Description |
---|---|
selector | A string containing a selector expression to match elements against. |
- returns: result of jQuery .is() method
- see: jQuery .is() method
.next()
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
- returns: result of jQuery .next() method
- see: jQuery .next() method
.nextAll()
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .nextAll() method
- see: jQuery .nextAll() method
.nextUntil(selector)
Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
Parameter | Description |
---|---|
selector | A string containing a selector expression to indicate where to stop matching following sibling elements. |
- returns: result of jQuery .nextUntil() method
- see: jQuery .nextUntil() method
.not(selector)
Remove elements from the set of matched elements.
Parameter | Description |
---|---|
selector | A string containing a selector expression to match elements against. |
- returns: result of jQuery .not() method
- see: jQuery .not() method
.offsetParent()
Get the closest ancestor element that is positioned.
- returns: result of jQuery .offsetParent() method
- see: jQuery .offsetParent() method
.parent()
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .parent() method
- see: jQuery .parent() method
.parents()
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .parents() method
- see: jQuery .parents() method
.parentsUntil(selector)
Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
Parameter | Description |
---|---|
selector | A string containing a selector expression to indicate where to stop matching ancestor elements. |
- returns: result of jQuery .parentsUntil() method
- see: jQuery .parentsUntil() method
.prev()
Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .prev() method
- see: jQuery .prev() method
.prevAll()
Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .prevAll() method
- see: jQuery .prevAll() method
.prevUntil(selector)
Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
Parameter | Description |
---|---|
selector | A string containing a selector expression to indicate where to stop matching preceding sibling elements. |
- returns: result of jQuery .prevUntil() method
- see: jQuery .prevUntil() method
.prop(propertyName)
Get the value of a property for the first element in the set of matched elements.
Parameter | Description |
---|---|
propertyName | The name of the property to get. |
- returns: result of jQuery .prop() method
- see: jQuery .prop() method
.siblings()
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
- returns: result of jQuery .siblings() method
- see: jQuery .siblings() method
.slice(start)
Reduce the set of matched elements to a subset specified by a range of indices.
Parameter | Description |
---|---|
start | An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. |
- returns: result of jQuery .slice() method
- see: jQuery .slice() method
.text()
Get the combined text contents of each element in the set of matched elements, including their descendants.
- returns: result of jQuery .text() method
- see: jQuery .text() method
.val()
Get the current value of the first element in the set of matched elements.
- returns: result of jQuery .val() method
- see: jQuery .val() method
FreezableElements
Everytime an Elements
expression is evaluated, the corresponding set of values needs to be computed. That means that the same Elements
expression, when evaluated multiple times, can evaluate into different sets.
This is a very handful behaviour, specially when interacting with elements, but it has a computational cost. To avoid computing the same set of results multiple times, a FreezableElements
expression memoizes evaluated results once they are not empty, so that next evaluations don't require computation.
.freeze()
Memoizes the result of an evaluation once it returns a non-empty set, so that next evaluations will return the exact same results instead of computing them again.
- returns: a new
Elements
that memoizes evaluation results once they are non-empty
ConditionalWebElements
Extends ConditionalElements
by adding methods that receive a CSS selector instead of Elements
. First, CSS selector is evaluated using
$(selector)
and then the same logic applies as in ConditionalElements
.and(selector)
Intersects both evaluated sets. For instance, if
this
evaluates into
{ A, B, C }
and
selector
evaluates into
{ B, C, D }
, then
this.and(selector)
evaluates into
{ B, C }
Parameter | Description |
---|---|
selector | a CSS selector |
- returns: new
Elements
that corresponds to the intersection ofthis
and elements represented byselector
.or(selector)
Represents the union both evaluated sets. For instance, if
this
evaluates into
{ A, B, C }
and
selector
evaluates into
{ B, C, D }
, then
this.or(selector)
evaluates into
{ A, B, C, D }
Parameter | Description |
---|---|
selector | a CSS selector |
- returns: new
Elements
that corresponds to the union ofthis
and elements represented byselector
.then(selector)
Evaluates into the elements represented by
selector
if and only if
this
evaluates into a non-empty set, otherwise returns an empty set.
For instance, if this
evaluates into { A, B }
and selector
evaluates into { B, C }
then this.then(selector)
evaluates into { B, C }
.
If this
evaluates into an empty set, then this.then(selector)
evaluates into an empty set.
Parameter | Description |
---|---|
selector | a CSS selector |
- returns: new
Elements
that evaluates into elements represented byselector
only and only ifthis
evaluates into a non-empty set, otherwise returns an empty set.
.unless(selector)
Evaluates into
this
if and only if elements represented by
selector
evaluates into a empty set, otherwise returns an empty set.
For instance, if this
evaluates into { A, B }
and selector
evaluates into { B, C }
then this.unless(selector)
evaluates into an empty set.
If selector
evaluates into an empty set, then this.unless(selector)
evaluates into { A, B }
.
Parameter | Description |
---|---|
selector | a CSS selector |
- returns: new
Elements
that evaluates intothis
only and only if elements represented byselector
evaluates into a empty set, otherwise returns an empty set.
.when(selector)
Evaluates into
this
if and only if elements represented by
selector
evaluates into a non-empty set, otherwise returns an empty set. Basically,
someElems.when(selector)
is equivalent to
$(selector).then(someElems)
.
Parameter | Description |
---|---|
selector | a CSS selector |
- returns: new
Elements
that evaluates intothis
only and only if elements represented byselector
evaluates into a non-empty set, otherwise returns an empty set.
ExtensionsWebElements
This interface provides useful jQuery extension methods for Minium WebElements
, like contained text filtering or attribute value filtering.
.containingText(text)
Filters elements which have a specified text as a substring.
Example:
wd.find("span").containingText("Hello")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello World</span>
Parameter | Description |
---|---|
text | the text to match |
- returns: filtered
WebElements
.containingVisibleText(text)
Filters elements which have a specified visible text as a substring.
Example:
wd.find("span").containingVisibleText("Hello")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello World</span>
Parameter | Description |
---|---|
text | the text to match |
- returns: filtered
WebElements
.displayed()
.matchingText(regex)
Filters elements which have text that matches the specified regular expression.
Example:
wd.find("span").matchingText(".* World")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello World</span>
Parameter | Description |
---|---|
regex | the regex |
- returns: filtered
WebElements
.matchingVisibleText(regex)
Filters elements which have visible text that matches the specified regular expression.
Example:
wd.find("span").matchingVisibleText(".* World")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello World</span>
Parameter | Description |
---|---|
regex | the regex |
- returns: filtered
WebElements
.selected()
.visible()
Filters elements tht are visible. Visibility is computed using :visible
jQuery CSS selector, as in `$(this).filter(":visible") `
Example:
wd.find("span").visible()evaluates
#span2
in the following scenario:
<span id="span1" style="display: none">Hello World</span> <span id="span2">Hello World</span>
- returns: filtered
WebElements
.visibleText()
.withAttr(name)
Filters elements that have an attribute.
Example:
wd.find("img").withAttr("alt")evaluates
#image2
in the following scenario:
<img id="image1" src="image1.gif"> <img id="image2" src="image2.gif" alt="Image 2">
Parameter | Description |
---|---|
name | the attribute name |
- returns: filtered
WebElements
.withCss(name)
Filters elements that have a style property.
Example:
wd.find("img").withCss("display")evaluates
#image2
in the following scenario:
<img id="image1" src="image1.gif"> <img id="image2" src="image2.gif" style="display: block">
Parameter | Description |
---|---|
name | the style property name |
- returns: filtered
WebElements
.withLabel(label)
Filters elements that have a label with the given text. That means that returned elements have the same id
than the for
attribute of the label
tag.
Example:
wd.find(":text").withLabel("Username")evaluates
#username
in the following scenario:
<label for="username">Username</label> <input type="text" id="username">
Parameter | Description |
---|---|
label | the label text |
- returns: filtered
WebElements
.withName(name)
Filters elements that have a name
attribute with a given value. This is very useful in form input elements.
Example:
wd.find(":password").withName("pass")evaluates
#password
in the following scenario:
<input id="password" type="password" name="pass">
Parameter | Description |
---|---|
name | the value for attribute |
name |
- returns: filtered
WebElements
.withProp(name)
Filters elements that have a property.
Example:
wd.find("img").withProp("title")evaluates
#image2
in the following scenario:
<img id="image1" src="image1.gif"> <img id="image2" src="image2.gif" title="Image 2">
Parameter | Description |
---|---|
name | the property name |
- returns: filtered
WebElements
.withText(text)
Filters elements which have a specified text.
Example:
wd.find("span").withText("Hello")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello</span>
Parameter | Description |
---|---|
text | the text to match |
- returns: filtered
WebElements
.withValue(value)
Filters elements that have a value
attribute with a given value. This is very useful in input elements.
Example:
wd.find(":button").withValue("Proceed")evaluates
#button
in the following scenario:
<input id="button" type="button" value="Proceed">
Parameter | Description |
---|---|
value | the value for attribute |
value |
- returns: filtered
WebElements
.withVisibleText(text)
Filters elements which have a specified visible text.
Example:
wd.find("span").withVisibleText("Hello")evaluates
#sometext
in the following scenario:
<span id="sometext">Hello</span>
Parameter | Description |
---|---|
text | the text to match |
- returns: filtered
WebElements
EvalWebElements
.eval(script)
.evalWebElements(script)
TargetLocatorWebElements
.documentRoots()
.frames()
.windows()
PositionWebElements
The Interface PositionWebElements.
.above(expr)
Returns elements above this element that match the expression.
Parameter | Description |
---|---|
expr | the expression to use for matching elements. |
- returns: elements
.below(expr)
Returns elements below this element that match the expression.
Parameter | Description |
---|---|
expr | the expression to use for matching elements. |
- returns: elements
.leftOf(expr)
Returns elements at the left this element that match the expression.
Parameter | Description |
---|---|
expr | the expression to use for matching elements. |
- returns: elements
.overlaps(expr)
Overlaps.
Parameter | Description |
---|---|
expr | the expr |
- returns: the t
.rightOf(expr)
Returns elements at the right of this element that match the expression.
Parameter | Description |
---|---|
expr | the expression to use for matching elements. |
- returns: elements