expectAlert

Check if a modal was opened

expectAlert(type: ("an alertbox" | "a confirmbox" | "a prompt"), reverse: boolean): void
Parameters
type (("an alertbox" | "a confirmbox" | "a prompt")) The type of modal that is expected
reverse (boolean) Check for opposite state
Returns
void

expectAlertText

Check the text of a modal

expectAlertText(type: ("an alertbox" | "a confirmbox" | "a prompt"), reverse: boolean, expectedText: string): void
Parameters
type (("an alertbox" | "a confirmbox" | "a prompt")) The type of modal that is expected
reverse (boolean) Check for opposite state
expectedText (string) The text to check against
Returns
void

handleAlert

Handle an alertbox/confirmbox/prompt

handleAlert(action: ("accept" | "dismiss"), type: ("alertbox" | "confirmbox" | "prompt")): void
Parameters
action (("accept" | "dismiss")) Action to perform
type (("alertbox" | "confirmbox" | "prompt")) Type of modal
Returns
void

setPromptText

Enter text into the current prompt

setPromptText(value: string): void
Parameters
value (string) The text to enter into the prompt
Returns
void

deleteCookie

Delete a cookie

deleteCookie(name: string): void
Parameters
name (string) The name of the cookie to delete
Returns
void

expectCookieExists

Check if a cookie with the given name exists

expectCookieExists(name: string, reverse: boolean): void
Parameters
name (string) The name of the cookie
reverse (boolean) Check for opposite state
Returns
void

expectCookieValue

Check the content of a cookie against a given value

expectCookieValue(name: string, reverse: boolean, expectedValue: string): void
Parameters
name (string) The name of the cookie
reverse (boolean) Check for opposite state
expectedValue (string) The value to check against
Returns
void

setCookie

Set a given cookie to a given value. When the cookies does not exist it will be created

setCookie(name: string, value: string): void
Parameters
name (string) The name of the cookie
value (string) The value of the cookie
Returns
void

defineTypedStep

Define a typed step

defineTypedStep(pattern: (RegExp | string), types: Array<ParamType>, options: IDefineStepOptions, code: StepDefinitionCode?): void
Parameters
pattern ((RegExp | string)) The regular expression used to match the step
types (Array<ParamType>) The param types used to map the expression matches to actual values
options (IDefineStepOptions) The options to use (optional)
code (StepDefinitionCode?) The function to execute
Returns
void
Related
paramType

pause

Pause execution for a given number of milliseconds

pause(ms: number): void
Parameters
ms (number) Number of milliseconds to pause
Returns
void

waitFor

Wait for the given element to be checked, enabled, selected, displayed, match/contain a text, match a value or to exist

waitFor(timeout: (number | undefined), element: ElementQuery, reverse: boolean, state: State?, value: string?): void
Parameters
timeout ((number | undefined) = 3000) Wait duration (optional)
element (ElementQuery) Element getter
reverse (boolean) Check for opposite state
state (State? = exist) State to check for
value (string?) The value to check for (in case of "match/contain the text/value")
Returns
void

waitForURL

Wait for the url or path to contain or match the specified value

waitForURL(timeout: (number | undefined), type: ("url" | "path"), reverse: boolean, state: State, expectedValue: string): void
Parameters
timeout ((number | undefined) = 3000) Wait duration (optional)
type (("url" | "path")) The type to check (url or path)
reverse (boolean) Check for opposite state
state (State) State to check for (contain or match)
expectedValue (string) The value to check for
Returns
void

ElementQuery

When called, returns a WebdriverIO.Element.

ElementQuery

Type: any

elementQuery

Get an element query for the specified text

elementQuery(name: string): ElementQuery
Parameters
name (string) The text to get the selectors by. Separate nesting child selectors by " -> ".
Returns
ElementQuery: An ElementQuery for a single element

ElementsQuery

When called, returns an array of WebdriverIO.Element.

ElementsQuery

Type: any

elementsQuery

Get an elements query for the specified text

elementsQuery(name: string): ElementsQuery
Parameters
name (string) The text to get the selectors by. Separate nesting child selectors by " -> ".
Returns
ElementsQuery: An ElementsQuery for multiple elements

addValue

Add a value to the current element value

addValue(value: string, element: ElementQuery): void
Parameters
value (string) The value to add to the element
element (ElementQuery) The element query
Returns
void

clearValue

Clear the value of a given input field

clearValue(element: ElementQuery): void
Parameters
element (ElementQuery) The element query
Returns
void

click

Perform a click action on the given element

click(action: Action, element: ElementQuery): void
Parameters
action (Action) The action to perform
element (ElementQuery) The element query
Returns
void

dragElement

Drag an element to a given destination

dragElement(source: ElementQuery, destination: ElementQuery): void
Parameters
source (ElementQuery) The element query for the source element
destination (ElementQuery) The element query for the destination element
Returns
void

expectClass

Check if the given element has the given class

expectClass(element: ElementQuery, reverse: boolean, expectedClassName: string): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedClassName (string) The class name to check
Returns
void

expectDisplayed

Check if the given element is (not) displayed

expectDisplayed(element: ElementQuery, reverse: boolean): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

expectEmpty

Check if the given element is empty

expectEmpty(type: ("element" | "button"), element: ElementQuery, reverse: boolean): void
Parameters
type (("element" | "button")) Element type
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

expectEnabled

Check if the given element is enabled

expectEnabled(element: ElementQuery, reverse: boolean): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

expectExists

Check if the given element exists in the DOM one or more times

expectExists(elements: ElementsQuery, reverse: boolean, exactly: number?): void
Parameters
elements (ElementsQuery) The elements query
reverse (boolean) Check for opposite state
exactly (number?) Check if the element exists exactly this number of times
Returns
void

expectFocus

Check if the given element has the focus

expectFocus(element: ElementQuery, reverse: boolean): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

expectOffset

Check the offset of the given element

expectOffset(element: ElementQuery, reverse: boolean, expectedPosition: number, axis: ("x" | "y")): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedPosition (number) The position to check against
axis (("x" | "y")) The axis to check on
Returns
void

expectProperty

Check the given property of the given element

expectProperty(checkCSS: boolean, attrName: string, element: ElementQuery, reverse: boolean, expectedValue: string): void
Parameters
checkCSS (boolean) Whether to check for a CSS property or an attribute
attrName (string) The name of the attribute to check
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedValue (string) The value to match against
Returns
void

attributeValue

when getting something with a color or font-weight WebdriverIO returns a object but we want to assert against a string

attributeValue

expectSameTextAs

Compare the contents of two elements with each other

expectSameTextAs(element1: ElementQuery, reverse: boolean, element2: ElementQuery): void
Parameters
element1 (ElementQuery) The element query for the first element
reverse (boolean) Check for opposite state
element2 (ElementQuery) The element query for the second element
Returns
void

expectSelected

Check the selected state of the given element

expectSelected(element: ElementQuery, reverse: boolean): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

expectSize

Check the dimensions of the given element

expectSize(dimension: ("width" | "height"), element: ElementQuery, reverse: boolean, expectedSize: number): void
Parameters
dimension (("width" | "height")) Dimension to check
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedSize (number) Expected size
Returns
void

expectText

Check if the given elements text is the same as the given text

expectText(type: ("element" | "button"), element: ElementQuery, reverse: boolean, expectedText: string): void
Parameters
type (("element" | "button")) Element type
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedText (string) The text to validate against
Returns
void

expectTextContains

Check if the given elements contains text

expectTextContains(type: ("element" | "button"), element: ElementQuery, reverse: boolean, expectedText: string): void
Parameters
type (("element" | "button")) Element type
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
expectedText (string) The text to check against
Returns
void

expectWithinViewport

Check if the given element is displayed inside the current viewport

expectWithinViewport(element: ElementQuery, reverse: boolean): void
Parameters
element (ElementQuery) The element query
reverse (boolean) Check for opposite state
Returns
void

moveTo

Move to the given element with an optional offset on an X and Y position

moveTo(element: ElementQuery, xOffset: number, yOffset: number): void
Parameters
element (ElementQuery) The element query
xOffset (number) X coordinate to move to
yOffset (number) Y coordinate to move to
Returns
void

pressKey

Perform a key press

pressKey(key: string): void
Parameters
key (string) The key to press
Returns
void

scrollTo

Scroll the page to the given element

scrollTo(element: ElementQuery): void
Parameters
element (ElementQuery) The element query
Returns
void

selectOption

Select an option of a select element

selectOption(type: Type, value: string, element: ElementQuery): void
Parameters
type (Type) Type of method to select by
value (string) Value to select by
element (ElementQuery) The element query
Returns
void

selectOptionByIndex

Select an option from a select element by it's index

selectOptionByIndex(index: number, element: ElementQuery): void
Parameters
index (number) The index of the option
element (ElementQuery) The element query
Returns
void

setValue

Set the value of the given input field to a new value

setValue(element: ElementQuery, value: string): void
Parameters
element (ElementQuery) The element query
value (string) The value to set the element to
Returns
void

failMessage

When an exception has been thrown, this will ensure its message will be changed.

failMessage
Parameters
fn (function (): void) A callback that might throw an exception
message (string) The message that should be set on the error object.
Returns
void

ucFirst

Turn the first character of the supplied string to upper-case.

ucFirst
Parameters
text (string) The text to change
Returns
string

dropFirstWord

Remove the first word of the supplied string (including whitespace).

dropFirstWord
Parameters
text (string) The text to change
Returns
string

lastOf

Get the last element of a list

lastOf
Parameters
list (Array<T>) The list to use
Returns
T

getUrlOrPath

Get the current url or path (if type !== 'url')

getUrlOrPath
Parameters
type (("url" | "path")) The type
Returns
string

getText

Get the text of an element

getText
Parameters
element (any) The element
Returns
any: The element text depending on the specified text method.
Related
setupTextMethod()

getTextOrValue

Get the text or value of an element or button

getTextOrValue
Parameters
type (("element" | "button")) Element type
element (WebdriverIO.Element) The element
Returns
string: The element value if type is not 'button', but the tagname is input, select or textarea. Otherwise the element text.

ParamType

Conversion function for input values from .feature files

ParamType

ParamTypeWithOptional

Conversion function for input values from .feature files, with possibility to use optional.

ParamTypeWithOptional

Extends ParamType

Instance Members
optional

ParamTypeBool

Conversion function for input values from .feature files, with possibility to use optional.

ParamTypeBool

Extends ParamTypeWithOptional

Instance Members
setTrue(trueValue)
setFalse(falseValue)

ParamTypeFormat

Conversion function for input values from .feature files, with possibility to use optional.

ParamTypeFormat

Extends ParamTypeWithOptional

Instance Members
format(pattern)

addOptional

Helper to add an 'optional' method to the function to make a parameter optional.

Parameters
fn (ParamType) The function to add the 'optional' attribute to.
Returns
ParamTypeWithOptional

paramType

Built-in ParamTypes. Use .optional() instead if it is optional.

paramType
Static Members
string
int
float
bool
selector
element
elements

closeAllButFirstTab

Close all tabs but the first one.

closeAllButFirstTab(): void
Returns
void

closeLastOpenedWindow

Close the last opened window

closeLastOpenedWindow(): void
Returns
void

expectNewWindow

Check if a new window or tab is opened

expectNewWindow(reverse: boolean?): void
Parameters
reverse (boolean?) Check for opposite state
Returns
void

expectNewWindowURL

Check if the given URL or path was opened in a new window

expectNewWindowURL(type: ("url" | "path"), expectedValue: string): void
Parameters
type (("url" | "path")) The type to check
expectedValue (string) The expected value to match against
Returns
void

expectTitle

Check the title of the current browser window

expectTitle(reverse: boolean, expectedTitle: string): void
Parameters
reverse (boolean) Check for opposite state
expectedTitle (string) The expected title
Returns
void

expectTitleContains

Check the title of the current browser window contains expected text/title

expectTitleContains(reverse: boolean, expectedTitle: string): void
Parameters
reverse (boolean) Check for opposite state
expectedTitle (string) The expected title
Returns
void

expectURL

Check if the current URL or path matches the given value

expectURL(type: ("url" | "path"), reverse: boolean, expectedValue: string): void
Parameters
type (("url" | "path")) The type to check
reverse (boolean) Check for opposite state
expectedValue (string) The expected value to match against
Returns
void

expectURLContains

Check if the given string is in the URL path

expectURLContains(type: ("url" | "path"), reverse: boolean, expectedPart: string): void
Parameters
type (("url" | "path")) The type to check
reverse (boolean) Check for opposite state
expectedPart (string) The string to check for
Returns
void

focusLastOpenedWindow

Focus the last opened window

focusLastOpenedWindow(): void
Returns
void

openURL

Open the given URL

openURL(type: ("url" | "path"), url: string): void
Parameters
type (("url" | "path")) Type of navigation
url (string) The URL or path to navigate to
Returns
void

resizeWindow

Resize the browser window

resizeWindow(width: number, height: number): void
Parameters
width (number) The width of the window to resize to
height (number) The height of the window to resize to
Returns
void