API Docs for: 0.2.7
Show:

Element Class

Defined in: lib/element.js:14
Module: Core
Parent Module: WebDriver

Object representing a DOM-Element

Constructor

Element

(
  • driver
  • parent
  • selector
  • id
)

Defined in lib/element.js:14

Parameters:

Methods

_logMethodCall

(
  • event
)
protected

Defined in lib/element.js:117

Logs a method call by an event

Parameters:

_requestJSON

(
  • method
  • path
  • [body]
)
protected

Defined in lib/element.js:131

Performs a context dependent JSON request for the current session. The result is parsed for errors.

Parameters:

Returns:

:

capture

(
  • [options]
)
Buffer

Defined in lib/element.js:540

Takes a screenshot of the document

Parameters:

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

    • [allPadding] Int optional

      Padding for all sides

    • [hPadding] Int optional

      Padding on left and right side of the element

    • [vPadding] Int optional

      Padding on the top and on the bottom of the element

    • [leftPadding] Int optional

      Padding on the left of the element

    • [rightPadding] Int optional

      Padding on the right of the element

    • [topPadding] Int optional

      Padding on the top of the element

    • [bottomPadding] Int optional

      Padding on the bottom of the element

Returns:

Buffer:

Binary image buffer

clear

()

Defined in lib/element.js:381

Clear the value of an input

compare

(
  • title
  • [options]
)
Boolean | Null

Defined in lib/element.js:586

Compares the screenshot of the element with a previous screenshot, showing differences between them

Parameters:

  • title String

    Unique title for comparison

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

    • [compare] Object optional

      Options for the comparison. See Blink-Diff documentation.

      • [id=1] Object optional
        Additional identifier to differentiate comparisons even more.
    • [allPadding] Int optional

      Padding for all sides

    • [hPadding] Int optional

      Padding on left and right side of the element

    • [vPadding] Int optional

      Padding on the top and on the bottom of the element

    • [leftPadding] Int optional

      Padding on the left of the element

    • [rightPadding] Int optional

      Padding on the right of the element

    • [topPadding] Int optional

      Padding on the top of the element

    • [bottomPadding] Int optional

      Padding on the bottom of the element

Returns:

Boolean | Null:

Are the screenshots the same? (NULL if there is nothing to compare to)

elementHandler

() Object

Defined in lib/element.js:196

Gets the internal selenium handler object Direct-access. No need to wait.

Returns:

elementId

() String

Defined in lib/element.js:185

Gets the value of the element id Direct-access. No need to wait.

Returns:

getAbsoluteCenter

() Object

Defined in lib/element.js:450

Gets the absolute center of an element

Returns:

Object:

{x: number, y: number}

getAttribute

(
  • attribute
)
String

Defined in lib/element.js:208

Gets the value of an attribute.

Parameters:

Returns:

getClasses

() String[]

Defined in lib/element.js:234

Gets a list of used classes

Returns:

getCssValue

() String

Defined in lib/element.js:297

Query the value of an element's computed CSS property. The CSS property to query should be specified using the CSS property name, not the JavaScript property name (e.g. background-color instead of backgroundColor).

Returns:

getElement

(
  • selector
  • [selectorType='css
)
Element

Defined in lib/element.js:481

Gets an element via a selector. Will throw an error if the element does not exist.

Parameters:

Returns:

getElements

(
  • selector
  • [selectorType='css
)
Array.

Defined in lib/element.js:502

Gets elements via a selector.

Parameters:

Returns:

Array.:

getFrame

() Object

Defined in lib/element.js:431

Get the frame of an element

Returns:

Object:

{x: number, y: number, width: number, height: number}

getPosition

() Object

Defined in lib/element.js:421

Gets the position of an element in the current view

Returns:

Object:

{x: number, y: number}

getPosition

() Object

Defined in lib/element.js:411

Gets the position of an element

Returns:

Object:

{x: number, y: number}

getRelativeCenter

() Object

Defined in lib/element.js:465

Gets the relative center of an element

Returns:

Object:

{x: number, y: number}

getSize

() Object

Defined in lib/element.js:401

Gets the size of an element

Returns:

Object:

{width: number, height: number}

getTagName

() String

Defined in lib/element.js:287

Gets the tag-name of an element.

Returns:

getText

() String

Defined in lib/element.js:248

Gets the text body of an element.

Returns:

getValue

() String

Defined in lib/element.js:273

Gets the value of an element.

Note: The element needs to have a 'value' attribute for this to work.

Returns:

hasClass

(
  • classStr
)
Boolean

Defined in lib/element.js:220

Does the element have a specific class?

Parameters:

Returns:

hasElement

(
  • selector
  • [selectorType='css
)
Boolean

Defined in lib/element.js:524

Does a specific element exist?

Parameters:

Returns:

hasText

(
  • text
)
Boolean

Defined in lib/element.js:258

Does the element have a specific text-string?

Parameters:

Returns:

isDisabled

() Boolean

Defined in lib/element.js:354

Return true if the form element is disabled

Returns:

isDisplayed

() Boolean

Defined in lib/element.js:311

Return true if the element is currently displayed on the page

Returns:

isEnabled

() Boolean

Defined in lib/element.js:344

Return true if the form element is enabled

Returns:

isEqual

(
  • element
)
Boolean

Defined in lib/element.js:332

Return true if the current element is equal to the supplied element

Parameters:

Returns:

isSelected

() Boolean

Defined in lib/element.js:322

Return true if the form element is selected

Returns:

mouse

() Mouse

Defined in lib/element.js:162

Gets the mouse object. Direct-access. No need to wait.

Returns:

screenshot

(
  • [options]
)
Buffer deprecated

Defined in lib/element.js:576

Deprecated: Use capture.

Takes a screenshot of the document

Parameters:

Returns:

Buffer:

Binary image buffer

sendKeys

(
  • str
)

Defined in lib/element.js:369

Type a string of characters into an input

Parameters:

submit

()

Defined in lib/element.js:391

Submit a form element

touch

() Touch

Defined in lib/element.js:173

Gets the touch object. Direct-access. No need to wait.

Returns:

Properties

SELECTOR_CLASS

String static

Defined in lib/element.js:38

Class-name selector type

SELECTOR_CSS

String static

Defined in lib/element.js:47

Css selector type, using the native css selector support

SELECTOR_ID

String static

Defined in lib/element.js:56

Id selector type

SELECTOR_NAME

String static

Defined in lib/element.js:65

Name selector type

SELECTOR_PARTIAL

String static

Defined in lib/element.js:84

Partial-link text selector type, finding a link that partially fits the selector. Only a part of the link-text needs to match.

SELECTOR_TAG

String static

Defined in lib/element.js:94

Tag-name selector type

SELECTOR_XPATH

String static

Defined in lib/element.js:103

XPath selector type