UNPKG

@badisi/wdio-harness

Version:

WebdriverIO support for Angular component test harnesses.

97 lines (96 loc) 4.66 kB
import { type ElementDimensions, type EventData, type ModifierKeys, type TestElement, TestKey, type TextOptions } from '@angular/cdk/testing'; /** Module augmentation to expose the host element as a public api */ declare module '@angular/cdk/testing' { interface ComponentHarness { element(): WebdriverIO.Element; } interface TestElement { element(): WebdriverIO.Element; } } /** * A `TestElement` implementation for WebdriverIO. */ export declare class WebdriverIOTestElement implements TestElement { readonly hostElement: WebdriverIO.Element; constructor(hostElement: WebdriverIO.Element); /** Return the host element. */ element(): WebdriverIO.Element; /** Blur the element. */ blur(): Promise<void>; /** Clear the element's input (for input and textarea elements only). */ clear(): Promise<void>; /** * 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. */ click(modifiers?: ModifierKeys): Promise<void>; /** Click the element at the element's center. */ click(location: 'center', modifiers?: ModifierKeys): Promise<void>; /** * Click the element at the specified coordinates relative to the top-left of the element. * @param relativeX Coordinate within the element, along the X-axis at which to click. * @param relativeY Coordinate within the element, along the Y-axis at which to click. * @param modifiers Modifier keys held while clicking */ click(relativeX: number, relativeY: number, modifiers?: ModifierKeys): Promise<void>; /** * Right clicks on the element at the specified coordinates relative to the top-left of it. * @param relativeX Coordinate within the element, along the X-axis at which to click. * @param relativeY Coordinate within the element, along the Y-axis at which to click. * @param modifiers Modifier keys held while clicking */ rightClick(relativeX: number, relativeY: number, modifiers?: ModifierKeys): Promise<void>; /** Focus the element. */ focus(): Promise<void>; /** Get the computed value of the given CSS property for the element. */ getCssValue(property: string): Promise<string>; /** Hovers the mouse over the element. */ hover(): Promise<void>; /** Moves the mouse away from the element. */ mouseAway(): Promise<void>; /** * 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. */ sendKeys(...keys: (string | TestKey)[]): Promise<void>; /** * 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. */ sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>; /** Gets the text from the element. */ text(options?: TextOptions): Promise<string>; /** * Sets the value of a `contenteditable` element. * @param value Value to be set on the element. */ setContenteditableValue(value: string): Promise<void>; /** Gets the value for the given attribute from the element. */ getAttribute(name: string): Promise<string | null>; /** Checks whether the element has the given class. */ hasClass(name: string): Promise<boolean>; /** Gets the dimensions of the element. */ getDimensions(): Promise<ElementDimensions>; /** Gets the value of a property of an element. */ getProperty(name: string): Promise<any>; /** Checks whether this element matches the given selector. */ matchesSelector(selector: string): Promise<boolean>; /** Checks whether the element is focused. */ isFocused(): Promise<boolean>; /** Sets the value of a property of an input. */ setInputValue(value: string): Promise<void>; /** Selects the options at the specified indexes inside of a native `select` element. */ selectOptions(...optionIndexes: number[]): Promise<void>; /** Dispatches an event with a particular name. */ dispatchEvent(name: string, data?: Record<string, EventData>): Promise<void>; /** Performs a key-down action. */ keyDown(value: string): Promise<void>; /** Performs a key-up action. */ keyUp(value: string): Promise<void>; /** Dispatches all the events that are part of a click event sequence. */ private dispatchClickEventSequence; /** Writes info to the console outputs. */ private logAction; }