leadfoot/Element

Inheritance

  1. leadfoot/Element
  2. 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.

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
clearValue(): Promise.<void>

Clears the value of a form element.

leadfoot/Element
click(): Promise.<void>

Clicks the element.

leadfoot/Element
equals(other: leadfoot/Element): Promise.<boolean>

Determines if this element is equal to another element.

leadfoot/Element
find(using: string, value: string): Promise.<leadfoot/Element>

Gets the first element within this element that matches the given query.

leadfoot/Element
findAll(using: string, value: string): Promise.<Array.<leadfoot/Element>>

Gets all elements within this element that match the given query.

leadfoot/Element
findAllByClassName(className: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given CSS class name.

leadfoot/Element
findAllByCssSelector(selector: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given CSS selector.

leadfoot/Element
findAllByLinkText(text: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given case-insensitive link text.

leadfoot/Element
findAllByName(name: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given name attribute.

leadfoot/Element
findAllByPartialLinkText(text: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element partially matching the given case-insensitive link text.

leadfoot/Element
findAllByTagName(tagName: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given HTML tag name.

leadfoot/Element
findAllByXpath(path: string): Promise.<Array.<leadfoot/Element>>

Gets all elements inside this element matching the given XPath selector.

leadfoot/Element
findByClassName(className: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given CSS class name.

leadfoot/Element
findByCssSelector(selector: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given CSS selector.

leadfoot/Element
findById(id: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given ID.

leadfoot/Element
findByLinkText(text: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given case-insensitive link text.

leadfoot/Element
findByName(name: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given name attribute.

leadfoot/Element
findByPartialLinkText(text: string): Promise.<leadfoot/Element>

Gets the first element inside this element partially matching the given case-insensitive link text.

leadfoot/Element
findByTagName(tagName: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given HTML tag name.

leadfoot/Element
findByXpath(path: string): Promise.<leadfoot/Element>

Gets the first element inside this element matching the given XPath selector.

leadfoot/Element
findDisplayed(using: string, value: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given query.

leadfoot/Element
findDisplayedByClassName(className: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given CSS class name.

leadfoot/Element
findDisplayedByCssSelector(selector: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given CSS selector.

leadfoot/Element
findDisplayedById(id: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given ID.

leadfoot/Element
findDisplayedByLinkText(text: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given case-insensitive link text.

leadfoot/Element
findDisplayedByName(name: string): Promise.<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
findDisplayedByTagName(tagName: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given HTML tag name.

leadfoot/Element
findDisplayedByXpath(path: string): Promise.<leadfoot/Element>

Gets the first displayed element inside this element matching the given XPath selector.

leadfoot/Element
getAttribute(name: string): Promise.<string>

Gets an attribute of the element.

leadfoot/Element
getComputedStyle(propertyName: string): Promise.<string>

Gets a CSS computed property value for the element.

leadfoot/Element
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).

leadfoot/Element
getProperty(name: string): Promise.<any>

Gets a property of the element.

leadfoot/Element
getSize(): Promise.<{width: number, height: number}>

Gets the size of the element, taking into account CSS transformations (if they are supported).

leadfoot/Element
getSpecAttribute(name: string): Promise.<string>

Gets a property or attribute of the element according to the WebDriver specification algorithm.

leadfoot/Element
getTagName(): Promise.<string>

Gets the tag name of the element.

leadfoot/Element
getVisibleText(): Promise.<string>

Gets the visible text within the element.

leadfoot/Element
isDisplayed(): Promise.<boolean>

Returns whether or not the element would be visible to an actual user.

leadfoot/Element
isEnabled(): Promise.<boolean>

Returns whether or not a form element can be interacted with.

leadfoot/Element
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).

leadfoot/Element
submit(): Promise.<void>

Submits the element, if it is a form, or the form belonging to the element, if it is a form element.

leadfoot/Element
type(value: string|Array.<string>): Promise.<void>

Types into the element.

leadfoot/Element
waitForDeleted(using: string, value: string): Promise.<void>

Waits for all elements inside this element that match the given query to be destroyed.

leadfoot/Element
waitForDeletedByClassName(className: string): Promise.<void>

Waits for all elements inside this element matching the given CSS class name to be destroyed.

leadfoot/Element
waitForDeletedByCssSelector(selector: string): Promise.<void>

Waits for all elements inside this element matching the given CSS selector to be destroyed.

leadfoot/Element
waitForDeletedById(id: string): Promise.<void>

Waits for all elements inside this element matching the given ID to be destroyed.

leadfoot/Element
waitForDeletedByLinkText(text: string): Promise.<void>

Waits for all elements inside this element matching the given case-insensitive link text to be destroyed.

leadfoot/Element
waitForDeletedByName(name: string): Promise.<void>

Waits for all elements inside this element matching the given name attribute to be destroyed.

leadfoot/Element
waitForDeletedByPartialLinkText(text: string): Promise.<void>

Waits for all elements inside this element partially matching the given case-insensitive link text to be destroyed.

leadfoot/Element
waitForDeletedByTagName(tagName: string): Promise.<void>

Waits for all elements inside this element matching the given HTML tag name to be destroyed.

leadfoot/Element
waitForDeletedByXpath(path: string): Promise.<void>

Waits for all elements inside this element matching the given XPath selector to be destroyed.

leadfoot/Element

Properties

(readonly) elementId: string

The opaque, remote-provided ID of the element.

(readonly) session: leadfoot/Session

The session that the element belongs to.

Methods

clearValue(): Promise.<void>

Clears the value of a form element.

click(): Promise.<void>

Clicks the element. This method works on both mouse and touch platforms.

equals(other: leadfoot/Element): Promise.<boolean>

Determines if this element is equal to another element.

Parameters

Name Type
other leadfoot/Element

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

findDisplayed(using: string, value: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByClassName(className: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByCssSelector(selector: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedById(id: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByLinkText(text: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByName(name: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByPartialLinkText(text: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByTagName(tagName: string): Promise.<leadfoot/Element>

Since

1.6

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.

findDisplayedByXpath(path: string): Promise.<leadfoot/Element>

Since

1.6

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.

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.

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.

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).

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.

getSize(): Promise.<{width: number, height: number}>

Gets the size of the element, taking into account CSS transformations (if they are supported).

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:

  1. If name is 'style', returns the style.cssText property of the element.
  2. If the attribute exists and is a boolean attribute, returns 'true' if the attribute is true, or null otherwise.
  3. If the element is an <option> element and name is 'value', returns the value attribute if it exists, otherwise returns the visible text content of the option.
  4. If the element is a checkbox or radio button and name is 'selected', returns 'true' if the element is checked, or null otherwise.
  5. If the returned value is expected to be a URL (e.g. element is <a> and attribute is href), returns the fully resolved URL from the href/src property of the element, not the attribute.
  6. If name is 'class', returns the className property of the element.
  7. If name is 'readonly', returns 'true' if the readOnly property is true, or null otherwise.
  8. If name corresponds to a property of the element, and the property is not an Object, return the property value coerced to a string.
  9. 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.

getTagName(): Promise.<string>

Gets the tag name of the element. For HTML documents, the value is always lowercase.

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.

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:

  1. Elements with display: none
  2. Elements with visibility: hidden
  3. Elements positioned outside of the viewport that cannot be scrolled into view
  4. Elements with opacity: 0
  5. Elements with no offsetWidth or offsetHeight

isEnabled(): Promise.<boolean>

Returns whether or not a form element can be interacted with.

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).

submit(): Promise.<void>

Submits the element, if it is a form, or the form belonging to the element, if it is a form element.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.