webdriverio
- Version 9.0.9
- Published
- 705 kB
- 27 dependencies
- MIT license
Install
npm i webdriverio
yarn add webdriverio
pnpm add webdriverio
Overview
Next-gen browser and mobile automation test framework for Node.js
Index
Variables
Functions
Classes
Interfaces
Type Aliases
- ActionType
- ActionTypes
- AddCommandFn
- BrowserCommandsType
- Button
- ButtonNames
- ClickOptions
- CustomLocatorReturnValue
- CustomStrategyFunction
- CustomStrategyReference
- DragAndDropCoordinate
- DragAndDropOptions
- ElementArray
- ElementCommandsType
- ElementFunction
- KeyActionType
- Matcher
- MockFilterOptions
- MoveToOptions
- MultiRemoteBrowserCommandsType
- MultiRemoteElementCommandsType
- MultiRemoteProtocolCommandsType
- NewWindowOptions
- Origin
- ReactSelectorOptions
- RestoreMap
- Selector
- SupportedScopes
- ThrottleOptions
- ThrottlePreset
- TouchActionParameter
- TouchActions
- WaitForOptions
- WaitUntilOptions
Variables
variable buttonValue
const buttonValue: readonly [0, 1, 2, 'left', 'middle', 'right'];
variable Key
const Key: { readonly Ctrl: 'WDIO_CONTROL'; readonly NULL: ''; readonly Cancel: ''; readonly Help: ''; readonly Backspace: ''; readonly Tab: ''; readonly Clear: ''; readonly Return: ''; readonly Enter: ''; readonly Shift: ''; readonly Control: ''; readonly Alt: ''; readonly Pause: ''; readonly Escape: ''; readonly Space: ''; readonly PageUp: ''; readonly PageDown: ''; readonly End: ''; readonly Home: ''; readonly ArrowLeft: ''; readonly ArrowUp: ''; readonly ArrowRight: ''; readonly ArrowDown: ''; readonly Insert: ''; readonly Delete: ''; readonly Semicolon: ''; readonly Equals: ''; readonly Numpad0: ''; readonly Numpad1: ''; readonly Numpad2: ''; readonly Numpad3: ''; readonly Numpad4: ''; readonly Numpad5: ''; readonly Numpad6: ''; readonly Numpad7: ''; readonly Numpad8: ''; readonly Numpad9: ''; readonly Multiply: ''; readonly Add: ''; readonly Separator: ''; readonly Subtract: ''; readonly Decimal: ''; readonly Divide: ''; readonly F1: ''; readonly F2: ''; readonly F3: ''; readonly F4: ''; readonly F5: ''; readonly F6: ''; readonly F7: ''; readonly F8: ''; readonly F9: ''; readonly F10: ''; readonly F11: ''; readonly F12: ''; readonly Command: ''; readonly ZenkakuHankaku: '';};
variable SevereServiceError
const SevereServiceError: typeof SevereServiceErrorImport;
Functions
function attach
attach: (attachOptions: AttachOptions) => Promise<WebdriverIO.Browser>;
function multiremote
multiremote: ( params: Capabilities.RequestedMultiremoteCapabilities, { automationProtocol }?: { automationProtocol?: string }) => Promise<WebdriverIO.MultiRemoteBrowser>;
WebdriverIO allows you to run multiple automated sessions in a single test. This is handy when you're testing features that require multiple users (for example, chat or WebRTC applications).
Instead of creating a couple of remote instances where you need to execute common commands like newSession() or url() on each instance, you can simply create a multiremote instance and control all browsers at the same time.
NOTE: Multiremote is not meant to execute all your tests in parallel. It is intended to help coordinate multiple browsers and/or mobile devices for special integration tests (e.g. chat applications).
Parameter params
capabilities to choose desired devices.
Parameter automationProtocol
All remote instances, the first result represents the capability defined first in the capability object, the second result the second capability and so on.
See Also
External document and example usage.
function remote
remote: ( params: Capabilities.WebdriverIOConfig, remoteModifier?: ( client: WebDriverTypes.Client, options: Capabilities.WebdriverIOConfig ) => WebDriverTypes.Client) => Promise<WebdriverIO.Browser>;
A method to create a new session with WebdriverIO.
NOTE: If you hit "error TS2694: Namespace 'global.WebdriverIO' has no exported member 'Browser'" when using typescript, add "@wdio/globals/types" into tsconfig.json's "types" array will solve it: { "compilerOptions": { "types": ["@wdio/globals/types"] } }
Parameter params
Options to create the session with
Parameter remoteModifier
Modifier function to change the monad object browser object with sessionId
See Also
Typescript setup
Classes
class KeyAction
class KeyAction extends BaseAction {}
constructor
constructor(instance: WebdriverIO.Browser, params?: BaseActionParams);
method down
down: (value: string) => this;
Generates a key down action.
Parameter value
key value
method up
up: (value: string) => this;
Generates a key up action.
Parameter value
key value
class PointerAction
class PointerAction extends BaseAction {}
constructor
constructor(instance: WebdriverIO.Browser, params?: BaseActionParams);
method cancel
cancel: () => this;
An action that cancels this pointer's current input.
method down
down: { (button?: Button): PointerAction; (button?: ButtonNames): PointerAction; (params?: PointerActionParams): PointerAction;};
Creates an action to press a single key
Parameter params
PointerActionParams
method move
move: { (params: PointerActionMoveParams): PointerAction; (x: number, y: number): PointerAction;};
Creates an action for moving the pointer
x
andy
pixels from the specifiedorigin
. Theorigin
may be defined as the pointers current position (e.g. "pointer"), the viewport (e.g. "viewport") or the center of a specific element.Parameter params
PointerActionMoveParams
method up
up: { (button?: Button): PointerAction; (button?: ButtonNames): PointerAction; (params?: PointerActionUpParams): PointerAction;};
Creates an action to release a single key.
Parameter params
PointerActionUpParams
class WheelAction
class WheelAction extends BaseAction {}
constructor
constructor(instance: WebdriverIO.Browser, params?: BaseActionParams);
method scroll
scroll: (params?: Partial<ScrollParams>) => this;
Scrolls a page to given coordinates or origin.
Interfaces
interface Action
interface Action {}
property actions
actions: (NoneActionEntity | PointerActionEntity | KeyActionEntity)[];
property id
id: string;
property parameters
parameters?: { pointerType: 'mouse' | 'pen' | 'touch';};
property type
type?: 'pointer' | 'key';
interface ActionParameter
interface ActionParameter {}
property actions
actions: Action[];
interface ActionParameters
interface ActionParameters {}
property pointerType
pointerType?: KeyActionType;
interface AttachOptions
interface AttachOptions extends Omit<WebDriverAttachOptions, 'capabilities'> {}
property capabilities
capabilities?: WebDriverAttachOptions['capabilities'];
property options
options?: Options.WebdriverIO;
property requestedCapabilities
requestedCapabilities?: WebDriverAttachOptions['capabilities'];
interface BaseActionParams
interface BaseActionParams {}
property id
id?: string;
property parameters
parameters?: ActionParameters;
interface Browser
interface Browser extends Omit<BrowserBase, 'on' | 'once'>, BidiEventHandler, BidiHandler, ProtocolCommands, BrowserCommandsType {}
interface BrowserBase
interface BrowserBase extends InstanceBase, CustomInstanceCommands<WebdriverIO.Browser> {}
a browser base that has everything besides commands which are defined for sync and async separately
property capabilities
capabilities: WebdriverIO.Capabilities;
capabilities of the browser instance
property isMultiremote
isMultiremote: false;
interface ChainablePromiseArray
interface ChainablePromiseArray extends AsyncIterators<WebdriverIO.Element> {}
property length
length: Promise<number>;
Amount of element fetched.
property parent
parent: Promise< WebdriverIO.Element | WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser>;
parent of the element if fetched via
$(parent).$(child)
property selector
selector: Promise<Selector>;
selector used to fetch this element, can be - undefined if element was created via
$({ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT-1' })
- a string iffindElement
was used and a reference was found - or a function if element was found via e.g.$(() => document.body)
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator<WebdriverIO.Element>;
method getElements
getElements: () => Promise<WebdriverIO.ElementArray>;
get the
WebdriverIO.Element[]
list
index signature
[n: number]: ChainablePromiseElement;
allow to access a specific index of the element set
interface ChainablePromiseElement
interface ChainablePromiseElement extends ChainablePromiseBaseElement, AsyncElementProto, Omit< WebdriverIO.Element, keyof ChainablePromiseBaseElement | keyof AsyncElementProto > {}
interface CustomInstanceCommands
interface CustomInstanceCommands<T> {}
method addCommand
addCommand: <IsElement extends boolean = false>( name: string, func: AddCommandFn | AddCommandFnScoped<T, IsElement>, attachToElement?: IsElement, proto?: Record<string, any>, instances?: Record< string, WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser >) => void;
add command to
browser
orelement
scope
method addLocatorStrategy
addLocatorStrategy: ( name: string, func: | ((selector: string, root: HTMLElement) => CustomLocatorReturnValue) | ((selector: string) => CustomLocatorReturnValue)) => void;
create custom selector
method overwriteCommand
overwriteCommand: < ElementKey extends | '$$' | '$' | 'addValue' | 'clearValue' | 'click' | 'custom$$' | 'custom$' | 'doubleClick' | 'dragAndDrop' | 'execute' | 'executeAsync' | 'getAttribute' | 'getCSSProperty' | 'getComputedRole' | 'getComputedLabel' | 'getElement' | 'getHTML' | 'getLocation' | 'getProperty' | 'getSize' | 'getTagName' | 'getText' | 'getValue' | 'isClickable' | 'isDisplayed' | 'isEnabled' | 'isEqual' | 'isExisting' | 'isFocused' | 'isSelected' | 'isStable' | 'moveTo' | 'nextElement' | 'parentElement' | 'previousElement' | 'react$$' | 'react$' | 'saveScreenshot' | 'scrollIntoView' | 'selectByAttribute' | 'selectByIndex' | 'selectByVisibleText' | 'setValue' | 'shadow$$' | 'shadow$' | 'touchAction' | 'waitForClickable' | 'waitForDisplayed' | 'waitForEnabled' | 'waitForExist' | 'waitForStable' | 'waitUntil', BrowserKey extends | '$$' | '$' | 'custom$$' | 'custom$' | 'execute' | 'executeAsync' | 'react$$' | 'react$' | 'saveScreenshot' | 'touchAction' | 'waitUntil' | 'action' | 'actions' | 'addInitScript' | 'call' | 'debug' | 'deleteCookies' | 'downloadFile' | 'emulate' | 'getCookies' | 'getPuppeteer' | 'getWindowSize' | 'keys' | 'mock' | 'SESSION_MOCKS' | 'mockClearAll' | 'mockRestoreAll' | 'newWindow' | 'pause' | 'reloadSession' | 'restore' | 'savePDF' | 'saveRecordingScreen' | 'scroll' | 'setCookies' | 'setTimeout' | 'setViewport' | 'setWindowSize' | 'switchWindow' | 'throttle' | 'throttleCPU' | 'throttleNetwork' | 'uploadFile' | 'url', IsElement extends boolean = false>( name: IsElement extends true ? ElementKey : BrowserKey, func: | OverwriteCommandFn<ElementKey, BrowserKey, IsElement> | OverwriteCommandFnScoped<ElementKey, BrowserKey, IsElement>, attachToElement?: IsElement, proto?: Record<string, any>, instances?: Record< string, WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser >) => void;
overwrite
browser
orelement
command
interface CustomThrottle
interface CustomThrottle {}
property downloadThroughput
downloadThroughput: number;
property latency
latency: number;
property offline
offline: boolean;
property uploadThroughput
uploadThroughput: number;
interface Element
interface Element extends ElementBase, ProtocolCommands, ElementCommandsType {}
Deprecated
use
WebdriverIO.Element
instead
interface ElementBase
interface ElementBase extends InstanceBase, ElementReference, CustomInstanceCommands<WebdriverIO.Element> {}
export a browser interface that can be used for typing plugins
property capabilities
capabilities: WebdriverIO.Capabilities;
capabilities of the browser instance
property ELEMENT
ELEMENT: string;
WebDriver element reference
property elementId
elementId: string;
WebDriver element reference
property error
error?: Error;
error response if element was not found
property index
index?: number;
index of the element if fetched with
$$
property isReactElement
isReactElement?: boolean;
true if element is a React component
property isShadowElement
isShadowElement?: boolean;
true if element was queried from a shadow root
property locator
locator?: remote.BrowsingContextLocator;
locator of the element WebDriver Bidi
property parent
parent: WebdriverIO.Element | WebdriverIO.Browser;
parent of the element if fetched via
$(parent).$(child)
property selector
selector: Selector;
selector used to fetch this element, can be - undefined if element was created via
$({ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT-1' })
- a string iffindElement
was used and a reference was found - or a functin if element was found via e.g.$(() => document.body)
interface ExtendedElementReference
interface ExtendedElementReference {}
property 'element-6066-11e4-a52e-4f735466cecf'
'element-6066-11e4-a52e-4f735466cecf': string;
property locator
locator: remote.BrowsingContextLocator;
interface InitScript
interface InitScript<Payload = undefined> {}
interface MockRequestOptions
interface MockRequestOptions {}
property requestWith
requestWith?: RequestWithOptions;
interface MultiRemoteBrowser
interface MultiRemoteBrowser extends MultiRemoteBrowserType {}
Deprecated
use
WebdriverIO.MultiRemoteBrowser
instead
interface MultiRemoteElement
interface MultiRemoteElement extends MultiRemoteElementType {}
Deprecated
use
WebdriverIO.MultiRemoteElement
instead
interface ParsedCSSValue
interface ParsedCSSValue {}
interface RequestWithOptions
interface RequestWithOptions {}
property body
body?: Overwrite<any, local.NetworkBeforeRequestSentParameters>;
property cookies
cookies?: Overwrite<Cookie[], local.NetworkBeforeRequestSentParameters>;
property headers
headers?: Overwrite< Record<string, string>, local.NetworkBeforeRequestSentParameters>;
property method
method?: Overwrite<Methods, local.NetworkBeforeRequestSentParameters>;
property url
url?: Overwrite<string, local.NetworkBeforeRequestSentParameters>;
interface RespondWithOptions
interface RespondWithOptions extends Omit<RequestWithOptions, 'url' | 'method'> {}
property statusCode
statusCode?: Overwrite<number, local.NetworkResponseCompletedParameters>;
Type Aliases
type ActionType
type ActionType = 'key' | 'pointer' | 'wheel';
type ActionTypes
type ActionTypes = 'press' | 'longPress' | 'tap' | 'moveTo' | 'wait' | 'release';
type AddCommandFn
type AddCommandFn = (...args: any[]) => any;
type BrowserCommandsType
type BrowserCommandsType = Omit<$BrowserCommands, keyof ChainablePrototype> & ChainablePrototype;
type Button
type Button = 0 | 1 | 2;
type ButtonNames
type ButtonNames = 'left' | 'middle' | 'right';
type ClickOptions
type ClickOptions = { button: Button | ButtonNames; x: number; y: number; skipRelease: boolean;};
type CustomLocatorReturnValue
type CustomLocatorReturnValue = | HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>;
type CustomStrategyFunction
type CustomStrategyFunction = ( ...args: any) => ElementReference | ElementReference[];
type CustomStrategyReference
type CustomStrategyReference = { strategy: CustomStrategyFunction; strategyName: string; strategyArguments: any[];};
type DragAndDropCoordinate
type DragAndDropCoordinate = { x: number; y: number;};
type DragAndDropOptions
type DragAndDropOptions = { duration?: number;};
type ElementArray
type ElementArray = ElementArrayExport;
type ElementCommandsType
type ElementCommandsType = Omit<$ElementCommands, keyof ChainablePrototype> & ChainablePrototype;
type ElementFunction
type ElementFunction = | ((elem: HTMLElement) => HTMLElement | undefined) | ((elem: HTMLElement) => (HTMLElement | undefined)[]);
type KeyActionType
type KeyActionType = 'mouse' | 'pen' | 'touch';
type Matcher
type Matcher = { name: string; args: Array<string | object>; class?: string;};
type MockFilterOptions
type MockFilterOptions = { method?: string | ((method: string) => boolean); requestHeaders?: | Record<string, string> | ((headers: Record<string, string>) => boolean); responseHeaders?: | Record<string, string> | ((headers: Record<string, string>) => boolean); statusCode?: number | ((statusCode: number) => boolean);};
type MoveToOptions
type MoveToOptions = { xOffset?: number; yOffset?: number;};
type MultiRemoteBrowserCommandsType
type MultiRemoteBrowserCommandsType = { [K in keyof Omit< BrowserCommandsType, ElementCommandNames | 'SESSION_MOCKS' | 'CDP_SESSIONS' >]: ( ...args: Parameters<BrowserCommandsType[K]> ) => Promise<ThenArg<ReturnType<BrowserCommandsType[K]>>[]>;} & MultiRemoteElementCommands;
type MultiRemoteElementCommandsType
type MultiRemoteElementCommandsType = { [K in keyof Omit<ElementCommandsType, ElementCommandNames>]: ( ...args: Parameters<ElementCommandsType[K]> ) => Promise<ThenArg<ReturnType<ElementCommandsType[K]>>[]>;} & MultiRemoteElementCommands;
type MultiRemoteProtocolCommandsType
type MultiRemoteProtocolCommandsType = { [K in keyof ProtocolCommands]: ( ...args: Parameters<ProtocolCommands[K]> ) => Promise<ThenArg<ReturnType<ProtocolCommands[K]>>[]>;};
type NewWindowOptions
type NewWindowOptions = { windowName?: string; windowFeatures?: string;};
type Origin
type Origin = 'pointer' | 'viewport';
type ReactSelectorOptions
type ReactSelectorOptions = { props?: object; state?: any[] | number | string | object | boolean;};
type RestoreMap
type RestoreMap = Map<SupportedScopes, (() => Promise<any>)[]>;
type Selector
type Selector = | string | ElementReference | ElementFunction | CustomStrategyReference | HTMLElement;
type SupportedScopes
type SupportedScopes = | 'geolocation' | 'userAgent' | 'colorScheme' | 'onLine' | 'clock' | 'device';
type ThrottleOptions
type ThrottleOptions = ThrottlePreset | CustomThrottle;
type ThrottlePreset
type ThrottlePreset = | 'offline' | 'GPRS' | 'Regular2G' | 'Good2G' | 'Regular3G' | 'Good3G' | 'Regular4G' | 'DSL' | 'WiFi' | 'online';
type TouchActionParameter
type TouchActionParameter = string | string[] | TouchAction | TouchAction[];
type TouchActions
type TouchActions = TouchActionParameter | TouchActionParameter[];
type WaitForOptions
type WaitForOptions = { timeout?: number; interval?: number; timeoutMsg?: string; reverse?: boolean; withinViewport?: boolean;};
type WaitUntilOptions
type WaitUntilOptions = { timeout?: number; timeoutMsg?: string; interval?: number;};
Package Files (8)
Dependencies (27)
- @types/node
- @types/sinonjs__fake-timers
- @wdio/config
- @wdio/logger
- @wdio/protocols
- @wdio/repl
- @wdio/types
- @wdio/utils
- archiver
- aria-query
- cheerio
- css-shorthand-properties
- css-value
- grapheme-splitter
- htmlfy
- import-meta-resolve
- is-plain-obj
- jszip
- lodash.clonedeep
- lodash.zip
- minimatch
- query-selector-shadow-dom
- resq
- rgb2hex
- serialize-error
- urlpattern-polyfill
- webdriver
Dev Dependencies (7)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/webdriverio
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/webdriverio)
- HTML<a href="https://www.jsdocs.io/package/webdriverio"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6126 ms. - Missing or incorrect documentation? Open an issue for this package.