API reference for Angular CDK testing-protractor

Import symbols from @angular/cdk/testing/protractor

A TestElement implementation for Protractor.

Deprecated
Properties
Name Description

element: ElementFinder

Methods
async
blur

Blur the element.

Returns
Promise<void>

Promise that resolves when the action completes.

async
clear

Clear the element's input (for input and textarea elements only).

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Click the element at the default location for the current environment. If you need to guarantee the element is clicked at a specific location, consider using click('center') or click(x, y) instead.

Parameters

modifiers?

ModifierKeys

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Click the element at the element's center.

Parameters

location

"center"

modifiers?

ModifierKeys

Returns
Promise<void>

Promise that resolves when the action completes.

async
click

Click the element at the specified coordinates relative to the top-left of the element.

Parameters

relativeX

number

relativeY

number

modifiers?

ModifierKeys

Returns
Promise<void>

Promise that resolves when the action completes.

async
dispatchEvent

Dispatches an event with a particular name.

Parameters

name

string

data?

Record<string, EventData>

Returns
Promise<void>

Promise that resolves when the action completes.

async
focus

Focus the element.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAttribute

Gets the value for the given attribute from the element.

Parameters

name

string

Returns
Promise<string | null>

async
getCssValue

Get the computed value of the given CSS property for the element.

Parameters

property

string

Returns
Promise<string>

async
getDimensions

Gets the dimensions of the element.

Returns
Promise<ElementDimensions>

async
getProperty

Gets the value of a property of an element.

Parameters

name

string

Returns
Promise<T>

async
hasClass

Checks whether the element has the given class.

Parameters

name

string

Returns
Promise<boolean>

async
hover

Hovers the mouse over the element.

Returns
Promise<void>

Promise that resolves when the action completes.

async
isFocused

Checks whether the element is focused.

Returns
Promise<boolean>

async
matchesSelector

Checks whether this element matches the given selector.

Parameters

selector

string

Returns
Promise<boolean>

async
mouseAway

Moves the mouse away from the element.

Returns
Promise<void>

Promise that resolves when the action completes.

async
rightClick
Parameters

...args

[ModifierKeys?] | ["center", ModifierKeys?] | [number, number, ModifierKeys?]

Returns
Promise<void>

Promise that resolves when the action completes.

async
selectOptions

Selects the options at the specified indexes inside of a native select element.

Parameters

...optionIndexes

number[]

Returns
Promise<void>

Promise that resolves when the action completes.

async
sendKeys

Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value.

Parameters

...keys

(string | TestKey)[]

Returns
Promise<void>

Promise that resolves when the action completes.

async
sendKeys

Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value.

Parameters

modifiers

ModifierKeys

...keys

(string | TestKey)[]

Returns
Promise<void>

Promise that resolves when the action completes.

async
setInputValue

Sets the value of a property of an input.

Parameters

value

string

Returns
Promise<void>

Promise that resolves when the action completes.

async
text

Gets the text from the element.

Parameters

options?

TextOptions

Returns
Promise<string>

A HarnessEnvironment implementation for Protractor.

Deprecated
Properties
Name Description

rootElement: TestElement

Methods
createEnvironment

Creates a HarnessLoader rooted at the given raw element.

Parameters

element

any

Returns
HarnessEnvironment<ElementFinder>

createTestElement

Creates a TestElement from a raw element.

Parameters

element

any

Returns
TestElement

documentRootLocatorFactory
Returns
LocatorFactory

async
forceStabilize

Flushes change detection and async tasks captured in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events.

Returns
Promise<void>

Promise that resolves when the action completes.

async
getAllChildLoaders
Parameters

selector

string

Returns
Promise<HarnessLoader[]>

async
getAllHarnesses
Parameters

query

HarnessQuery<T>

Returns
Promise<T[]>

async
getAllRawElements

Gets a list of all elements matching the given selector under this environment's root element.

Parameters

selector

string

Returns
Promise<ElementFinder[]>

async
getChildLoader
Parameters

selector

string

Returns
Promise<HarnessLoader>

getDocumentRoot

Gets the root element for the document.

Returns
ElementFinder

async
getHarness
Parameters

query

HarnessQuery<T>

Returns
Promise<T>

static
getNativeElement

Gets the ElementFinder corresponding to the given TestElement.

Parameters

el

TestElement

Returns
ElementFinder

async
harnessLoaderFor
Parameters

selector

string

Returns
Promise<HarnessLoader>

async
harnessLoaderForAll
Parameters

selector

string

Returns
Promise<HarnessLoader[]>

async
harnessLoaderForOptional
Parameters

selector

string

Returns
Promise<HarnessLoader | null>

static
loader

Creates a HarnessLoader rooted at the document root.

Parameters

options?

ProtractorHarnessEnvironmentOptions

Returns
HarnessLoader

locatorFor
Parameters

...queries

T

Returns
AsyncFactoryFn<LocatorFnResult<T>>

locatorForAll
Parameters

...queries

T

Returns
AsyncFactoryFn<LocatorFnResult<T>[]>

locatorForOptional
Parameters

...queries

T

Returns
AsyncFactoryFn<LocatorFnResult<T> | null>

async
rootHarnessLoader
Returns
Promise<HarnessLoader>

Options to configure the environment.

Deprecated
Properties
Name Description

queryFn: (selector: string, root: ElementFinder) => ElementArrayFinder

The query function used to find DOM elements.