Class: Component

Component

Component

Constructor

new Component(definition)

A Component can be defined application-wide or be a part of a page.
You can define elements and methods on a Component.

Parameters:
Name Type Description
definition Component~ComponentDefinition
Mixes In:
Source:

Methods

(static) equals(a, b) → {Boolean}

Determines whether two components are equal by deep comparison

Parameters:
Name Type Description
a Component
b Component
Source:
Returns:
Type
Boolean

(static) mixin(inheritor)

Provides access to methods that are appropriate for supporting
Component in other classes such as View

Parameters:
Name Type Description
inheritor Constructor
Source:

$component(component, definitionopt) → {Component}

Copy an existing component onto this component.
The locator for the copied component and its children will become relative to this component.
Warning: this method also copies any methods, which may still have reference to the original component.

Parameters:
Name Type Attributes Description
component Component
definition Component~ComponentDefinition <optional>
Mixes In:
Source:
Throws:

If first argument is not a Component

Type
Error
Returns:

A deep copy of the component

Type
Component

$hierarchy() → {Array.<(Component|View|Page)>}

Travels up the Component tree and returns an array containing the
Component and all of its parents, in the order found.

Mixes In:
Source:
Returns:
Type
Array.<(Component|View|Page)>

all(method, then)

Creates an iterator for all the elements matching this component's locator and accepts a
function of that component type

Parameters:
Name Type Description
method function
then function

callback function

Source:
Example
component.all(function(element) { element.click(); });

click()

Clicks on the element using the custom angular.anchor dsl

Source:

containsText()

Performs an angular expectation testing whether this element contains any text

Source:

count()

Source:

dragTo(x, y)

Simulates browser drag and drop

Parameters:
Name Type Description
x Number
y Number
Source:

element() → {ElementFinder}

Source:
Returns:

Returns the ElementFinder for this component

Type
ElementFinder

enter(value)

Enters a value into an input field

Parameters:
Name Type Description
value String
Source:

expectCount() → {Object}

Source:
Returns:
Type
Object
Example
<pre>
component.expectCount().greaterThan(3);
component.expectCount().lessThan(7);
component.expectCount().toBe(2);
</pre>

focus()

Gives focus to the component

Source:

isActive()

Tests this component for having the 'active' class

Source:

isDisabled()

Tests this component for having the 'disabled' class

Source:

isEnabled()

Tests this component for not having the 'disabled' class

Source:

isFullyDisplayed()

Checks that all children are visible.
For a component without children, use isVisible()

Source:

isHidden()

Performs an expectation testing whether component is hidden on page

Source:

isNotEmpty()

Performs an angular expectation testing whether this element is not empty

Source:

isNotPresent()

Performs an expectation testing whether component is not in document

Source:

isNotSelected()

Tests that this component does not have a 'selected' class

Source:

isSelected()

Tests this component for having the 'selected' class

Source:

isVisible()

Performs an expectation testing whether this component is visible

Source:

keypress(keyCode)

Simulates keypress of given keycode

Parameters:
Name Type Description
keyCode Number
Source:

matches(match)

Performs an angular expectation testing whether this element's text matches the given
string or regular expression

Parameters:
Name Type Description
match RegExp
Source:
Example
component.matches(/hello world/);

nth(number)

Return the nth element matching this component's locator

Parameters:
Name Type Description
number Number
Source:
Example
component.nth(3).isDisplayed();

opensNewWindow()

Tests this component for having the '_blank' href target

Source:

set(definition)

Sets the properties for a Component. Changes are recursed down to children.

Parameters:
Name Type Description
definition Component~ComponentDefinition
Source:
Example
component.set({name: 'list', locator: '.itemList', parent: null});

text()

Retrieves the text from an element and passes the value to the provided callback function

Source:
Example
expect(component.text()).toMatch(/hello world/ig);

value(value)

Retrieves or enters a value into an input field

Parameters:
Name Type Description
value String
Source:

Type Definitions

ComponentDefinition

The definition object for a Component

Type:
  • Object
Properties:
Name Type Attributes Description
name String

the name of the component

locator String

the locator for this component (can be a css selector or a ProtractorBy locator)

parent Component | View | Page <optional>

the parent component for this component. $locator should be relative to this parent.

methods Object.<String, function()> <optional>

a map of functions to be added as instance methods to this component

components Array.<ComponentDefinition> <optional>

sub-components to add to this Component

Source: