leadfoot/Element
Inheritance
- leadfoot/Element
- Object
new (require("leadfoot/Element"))(elementId: string|leadfoot/Element|Object, session: leadfoot/Session)
An Element represents a DOM or UI element within the remote environment.
Parameters
Name | Type | Description |
---|---|---|
elementId |
string|leadfoot/Element|Object |
The ID of the element, as provided by the remote. |
session |
leadfoot/Session |
The session that the element belongs to. |
Source
All Properties
Property | Defined by |
---|---|
elementId: string
(readonly)
The opaque, remote-provided ID of the element. |
leadfoot/Element |
(readonly)
The session that the element belongs to. |
leadfoot/Element |
All Methods
Method | Defined by |
---|---|
Clears the value of a form element. |
leadfoot/Element |
Clicks the element. |
leadfoot/Element |
Determines if this element is equal to another element. |
leadfoot/Element |
Gets the first element within this element that matches the given query. |
leadfoot/Element |
Gets all elements within this element that match the given query. |
leadfoot/Element |
Gets all elements inside this element matching the given CSS class name. |
leadfoot/Element |
Gets all elements inside this element matching the given CSS selector. |
leadfoot/Element |
Gets all elements inside this element matching the given case-insensitive link text. |
leadfoot/Element |
Gets all elements inside this element matching the given name attribute. |
leadfoot/Element |
Gets all elements inside this element partially matching the given case-insensitive link text. |
leadfoot/Element |
Gets all elements inside this element matching the given HTML tag name. |
leadfoot/Element |
Gets all elements inside this element matching the given XPath selector. |
leadfoot/Element |
Gets the first element inside this element matching the given CSS class name. |
leadfoot/Element |
Gets the first element inside this element matching the given CSS selector. |
leadfoot/Element |
Gets the first element inside this element matching the given ID. |
leadfoot/Element |
Gets the first element inside this element matching the given case-insensitive link text. |
leadfoot/Element |
Gets the first element inside this element matching the given name attribute. |
leadfoot/Element |
Gets the first element inside this element partially matching the given case-insensitive link text. |
leadfoot/Element |
Gets the first element inside this element matching the given HTML tag name. |
leadfoot/Element |
Gets the first element inside this element matching the given XPath selector. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given query. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given CSS class name. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given CSS selector. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given ID. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given case-insensitive link text. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given name attribute. |
leadfoot/Element |
Gets the first displayed element inside this element partially matching the given case-insensitive link text. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given HTML tag name. |
leadfoot/Element |
Gets the first displayed element inside this element matching the given XPath selector. |
leadfoot/Element |
Gets an attribute of the element. |
leadfoot/Element |
Gets a CSS computed property value for the element. |
leadfoot/Element |
Gets the position of the element relative to the top-left corner of the document, taking into account scrolling and CSS transformations (if they are supported). |
leadfoot/Element |
Gets a property of the element. |
leadfoot/Element |
Gets the size of the element, taking into account CSS transformations (if they are supported). |
leadfoot/Element |
Gets a property or attribute of the element according to the WebDriver specification algorithm. |
leadfoot/Element |
Gets the tag name of the element. |
leadfoot/Element |
Gets the visible text within the element. |
leadfoot/Element |
Returns whether or not the element would be visible to an actual user. |
leadfoot/Element |
Returns whether or not a form element can be interacted with. |
leadfoot/Element |
Returns whether or not a form element is currently selected (for drop-down options and radio buttons), or whether or not the element is currently checked (for checkboxes). |
leadfoot/Element |
Submits the element, if it is a form, or the form belonging to the element, if it is a form element. |
leadfoot/Element |
Types into the element. |
leadfoot/Element |
Waits for all elements inside this element that match the given query to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given CSS class name to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given CSS selector to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given ID to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given case-insensitive link text to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given name attribute to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element partially matching the given case-insensitive link text to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given HTML tag name to be destroyed. |
leadfoot/Element |
Waits for all elements inside this element matching the given XPath selector to be destroyed. |
leadfoot/Element |
Properties
(readonly) elementId: string
(readonly) session: leadfoot/Session
Methods
clearValue(): Promise.<void>
click(): Promise.<void>
Clicks the element. This method works on both mouse and touch platforms.
Source
equals(other: leadfoot/Element): Promise.<boolean>
Determines if this element is equal to another element.
Parameters
Name | Type |
---|---|
other |
leadfoot/Element |
Source
find(using: string, value: string): Promise.<leadfoot/Element>
Gets the first element within this element that matches the given query.
Parameters
Name | Type | Description |
---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
See
- leadfoot/Session#setFindTimeout to set the amount of time it the remote environment should spend waiting for an element that does not exist at the time of the `find` call before timing out.
Source
findAll(using: string, value: string): Promise.<Array.<leadfoot/Element>>
Gets all elements within this element that match the given query.
Parameters
Name | Type | Description |
---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
Source
findAllByClassName(className: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given CSS class name.
Parameters
Name | Type | Description |
---|---|---|
className |
string |
The CSS class name to search for. |
Source
findAllByCssSelector(selector: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given CSS selector.
Parameters
Name | Type | Description |
---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findAllByLinkText(text: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given case-insensitive link text.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The link text of the element. |
Source
findAllByName(name: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given name attribute.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the element. |
Source
findAllByPartialLinkText(text: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element partially matching the given case-insensitive link text.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The partial link text of the element. |
Source
findAllByTagName(tagName: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given HTML tag name.
Parameters
Name | Type | Description |
---|---|---|
tagName |
string |
The tag name of the element. |
Source
findAllByXpath(path: string): Promise.<Array.<leadfoot/Element>>
Gets all elements inside this element matching the given XPath selector.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
The XPath selector to search for. |
Source
findByClassName(className: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given CSS class name.
Parameters
Name | Type | Description |
---|---|---|
className |
string |
The CSS class name to search for. |
Source
findByCssSelector(selector: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given CSS selector.
Parameters
Name | Type | Description |
---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findById(id: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given ID.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the element. |
Source
findByLinkText(text: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given case-insensitive link text.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The link text of the element. |
Source
findByName(name: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given name attribute.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the element. |
Source
findByPartialLinkText(text: string): Promise.<leadfoot/Element>
Gets the first element inside this element partially matching the given case-insensitive link text.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The partial link text of the element. |
Source
findByTagName(tagName: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given HTML tag name.
Parameters
Name | Type | Description |
---|---|---|
tagName |
string |
The tag name of the element. |
Source
findByXpath(path: string): Promise.<leadfoot/Element>
Gets the first element inside this element matching the given XPath selector.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
The XPath selector to search for. |
Source
findDisplayed(using: string, value: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given query. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
Source
findDisplayedByClassName(className: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given CSS class name. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
className |
string |
The CSS class name to search for. |
Source
findDisplayedByCssSelector(selector: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given CSS selector. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
selector |
string |
The CSS selector to search for. |
Source
findDisplayedById(id: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given ID. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the element. |
Source
findDisplayedByLinkText(text: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given case-insensitive link text. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The link text of the element. |
Source
findDisplayedByName(name: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given name attribute. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the element. |
Source
findDisplayedByPartialLinkText(text: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element partially matching the given case-insensitive link text. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The partial link text of the element. |
Source
findDisplayedByTagName(tagName: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given HTML tag name. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
tagName |
string |
The tag name of the element. |
Source
findDisplayedByXpath(path: string): Promise.<leadfoot/Element>
Since
Gets the first displayed element inside this element matching the given XPath selector. This is inherently slower than leadfoot/Element#find, so should only be used in cases where the visibility of an element cannot be ensured in advance.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
The XPath selector to search for. |
Source
getAttribute(name: string): Promise.<string>
Gets an attribute of the element.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the attribute. |
Returns
The value of the attribute, or
null
if no such attribute exists.
See
- Element#getProperty to retrieve an element property.
Source
getComputedStyle(propertyName: string): Promise.<string>
Gets a CSS computed property value for the element.
Parameters
Name | Type | Description |
---|---|---|
propertyName |
string |
The CSS property to retrieve. This argument must be hyphenated, not camel-case. |
Source
getPosition(): Promise.<{x: number, y: number}>
Gets the position of the element relative to the top-left corner of the document, taking into account scrolling and CSS transformations (if they are supported).
Source
getProperty(name: string): Promise.<any>
Gets a property of the element.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the property. |
Returns
The value of the property.
See
- Element#getAttribute to retrieve an element attribute.
Source
getSize(): Promise.<{width: number, height: number}>
Gets the size of the element, taking into account CSS transformations (if they are supported).
Source
getSpecAttribute(name: string): Promise.<string>
Gets a property or attribute of the element according to the WebDriver specification algorithm. Use of this method is not recommended; instead, use leadfoot/Element#getAttribute to retrieve DOM attributes and leadfoot/Element#getProperty to retrieve DOM properties.
This method uses the following algorithm on the server to determine what value to return:
- If
name
is 'style', returns thestyle.cssText
property of the element. - If the attribute exists and is a boolean attribute, returns 'true' if the attribute is true, or null otherwise.
- If the element is an
<option>
element andname
is 'value', returns thevalue
attribute if it exists, otherwise returns the visible text content of the option. - If the element is a checkbox or radio button and
name
is 'selected', returns 'true' if the element is checked, or null otherwise. - If the returned value is expected to be a URL (e.g. element is
<a>
and attribute ishref
), returns the fully resolved URL from thehref
/src
property of the element, not the attribute. - If
name
is 'class', returns theclassName
property of the element. - If
name
is 'readonly', returns 'true' if thereadOnly
property is true, or null otherwise. - If
name
corresponds to a property of the element, and the property is not an Object, return the property value coerced to a string. - If
name
corresponds to an attribute of the element, return the attribute value.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The property or attribute name. |
Returns
The value of the attribute as a string, or
null
if no such property or attribute exists.
Source
getTagName(): Promise.<string>
Gets the tag name of the element. For HTML documents, the value is always lowercase.
Source
getVisibleText(): Promise.<string>
Gets the visible text within the element. <br>
elements are converted to line breaks in the returned
text, and whitespace is normalised per the usual XML/HTML whitespace normalisation rules.
Source
isDisplayed(): Promise.<boolean>
Returns whether or not the element would be visible to an actual user. This means that the following types of elements are considered to be not displayed:
- Elements with
display: none
- Elements with
visibility: hidden
- Elements positioned outside of the viewport that cannot be scrolled into view
- Elements with
opacity: 0
- Elements with no
offsetWidth
oroffsetHeight
Source
isEnabled(): Promise.<boolean>
isSelected(): Promise.<boolean>
Returns whether or not a form element is currently selected (for drop-down options and radio buttons), or whether or not the element is currently checked (for checkboxes).
Source
submit(): Promise.<void>
Submits the element, if it is a form, or the form belonging to the element, if it is a form element.
Source
type(value: string|Array.<string>): Promise.<void>
Types into the element. This method works the same as the leadfoot/Session#pressKeys method except that any modifier keys are automatically released at the end of the command. This method should be used instead of leadfoot/Session#pressKeys to type filenames into file upload fields.
Since 1.5, if the WebDriver server supports remote file uploads, and you type a path to a file on your local computer, that file will be transparently uploaded to the remote server and the remote filename will be typed instead. If you do not want to upload local files, use leadfoot/Session#pressKeys instead.
Parameters
Name | Type | Description |
---|---|---|
value |
string|Array.<string> |
The text to type in the remote environment. See leadfoot/Session#pressKeys for more information. |
Source
waitForDeleted(using: string, value: string): Promise.<void>
Waits for all elements inside this element that match the given query to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
using |
string |
The element retrieval strategy to use. See leadfoot/Session#find for options. |
value |
string |
The strategy-specific value to search for. See leadfoot/Session#find for details. |
Source
waitForDeletedByClassName(className: string): Promise.<void>
Waits for all elements inside this element matching the given CSS class name to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
className |
string |
The CSS class name to search for. |
Source
waitForDeletedByCssSelector(selector: string): Promise.<void>
Waits for all elements inside this element matching the given CSS selector to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
selector |
string |
The CSS selector to search for. |
Source
waitForDeletedById(id: string): Promise.<void>
Waits for all elements inside this element matching the given ID to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
id |
string |
The ID of the element. |
Source
waitForDeletedByLinkText(text: string): Promise.<void>
Waits for all elements inside this element matching the given case-insensitive link text to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The link text of the element. |
Source
waitForDeletedByName(name: string): Promise.<void>
Waits for all elements inside this element matching the given name attribute to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
name |
string |
The name of the element. |
Source
waitForDeletedByPartialLinkText(text: string): Promise.<void>
Waits for all elements inside this element partially matching the given case-insensitive link text to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
text |
string |
The partial link text of the element. |
Source
waitForDeletedByTagName(tagName: string): Promise.<void>
Waits for all elements inside this element matching the given HTML tag name to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
tagName |
string |
The tag name of the element. |
Source
waitForDeletedByXpath(path: string): Promise.<void>
Waits for all elements inside this element matching the given XPath selector to be destroyed.
Parameters
Name | Type | Description |
---|---|---|
path |
string |
The XPath selector to search for. |