Options
All
  • Public
  • Public/Protected
  • All
Menu

wdio-mobile-utils

Index

Gesture Type aliases

Coordinate

Coordinate: { x: number; y: number }

Type declaration

  • x: number
  • y: number

Variables

Const CHROME_APP_ID

CHROME_APP_ID: "com.android.chrome" = "com.android.chrome"

Const DEFAULT_TIMEOUT

DEFAULT_TIMEOUT: 60000 = 60000

Const SAFARI_BUNDLE_ID

SAFARI_BUNDLE_ID: "com.apple.mobilesafari" = "com.apple.mobilesafari"

Alert Functions

acceptAlert

  • acceptAlert(): void
  • Accepts the alert in a cross-platform way. For example, this would press the "OK" or "Yes" button.

    Returns void

dismissAlert

  • dismissAlert(): void
  • Dismisses the alert in a cross-platform way. For example, this would press the "Close", "Cancel" or "No" button.

    Returns void

getAlertText

  • getAlertText(wait: false): string | null
  • Returns the text of an alert.

    Parameters

    • wait: false

      whether to wait for an alert to appear or not

    Returns string | null

    the text of the alert or {@code null} if no alert is displayed

isAlertDisplayed

  • isAlertDisplayed(): boolean
  • Returns whether or not a native alert is shown.

    Returns boolean

waitForAlertDisplayed

  • waitForAlertDisplayed(): Element
  • Waits for a native alert to be shown.

    Returns Element

App Utility Functions

isAppState

  • isAppState(state: APP_RUNNING_STATE, wait?: boolean, appId?: undefined | string, bundleId?: undefined | string, timeout?: number): boolean
  • Returns true if the specified app state is met.

    Parameters

    • state: APP_RUNNING_STATE

      which state to check for

    • Default value wait: boolean = false

      If set to true, will wait for the app to be running.

    • Optional appId: undefined | string

      ID of the app (Android)

    • Optional bundleId: undefined | string

      bundle id of the app (iOS)

    • Default value timeout: number = DEFAULT_TIMEOUT

      how long to wait until the state is met

    Returns boolean

isBrowserAppState

  • Returns true if the specified app state is met for Safari.

    Parameters

    • state: APP_RUNNING_STATE

      Which state should be checked for

    • Default value wait: boolean = false

      If set to true, will wait for the app to be running.

    Returns boolean

openApp

  • openApp(wait?: boolean, appId?: undefined | string, bundleId?: undefined | string): void
  • Opens the app.

    Parameters

    • Default value wait: boolean = false

      whether or not the start of the app should be awaited

    • Optional appId: undefined | string

      ID of the app (Android)

    • Optional bundleId: undefined | string

      bundle id of the app (iOS)

    Returns void

openSafari

  • openSafari(): void

queryAppState

  • queryAppState(appId?: undefined | string, bundleId?: undefined | string): APP_RUNNING_STATE

Deeplink Functions

openDeeplink

  • openDeeplink(path: string, appId?: undefined | string, bundleId?: undefined | string, timeout?: number): void
  • Opens the app with the specified deeplink path routing to the view that should be shown.

    note

    When using Appium <1.17.0 with iOS, it will only work with English system language. Upgrade to Appium >=1.17.0 for support of all locales on iOS. Support for Appium <1.17.0 will be dropped in the future.

    Parameters

    • path: string

      to the deeplink

    • Optional appId: undefined | string

      ID of the app (Android)

    • Optional bundleId: undefined | string

      bundle id of the app (iOS)

    • Default value timeout: number = DEFAULT_TIMEOUT

      how long to wait in each step of the process until the deeplink has been opened

    Returns void

Environment Functions

isIosSimulator

  • isIosSimulator(): boolean
  • Returns whether the test is currently running on an iOS Simulator or not.

    Returns boolean

General Utility Functions

getAccessibilityIdOfElement

  • getAccessibilityIdOfElement(element: Element): string
  • Returns the accessibilityId of an element.

    Parameters

    • element: Element

      of which to get the accessibilityId

    Returns string

    the accessibilityId of {@code element}

removeStartingTilde

  • removeStartingTilde(key: string): string
  • Removes, if present, the ~ character in the beginning of a string. This is useful in cases where the accessibilityId can be passed in by the developer, but needs to be without a ~ in front. This makes sure even if the accessibilityId contains a ~ that is not allowed, that it's properly removed, providing greater convenience.

    Parameters

    • key: string

    Returns string

Gesture Functions

checkIfDisplayedWithScrollDown

  • checkIfDisplayedWithScrollDown(element: Element, maxScrolls: number, amount?: number): void
  • Check if an element is visible and if not scroll down a portion of the screen to check if it visible after a x amount of scrolls.

    author

    Wim Selles | wswebcreation

    Parameters

    • element: Element

      to check for if displayed

    • maxScrolls: number

      maximum amount of scrolls to perform until the element is visible

    • Default value amount: number = 0

      current amount of scrolls

    Returns void

swipe

  • Swipes from coordinate (from) to the new coordinate (to). The given coordinates are in pixels.

    author

    Wim Selles | wswebcreation

    Example

    // This is a swipe to the left
    const from = { x: 50, y:50 }
    const to = { x: 25, y:50 }

    Parameters

    • from: Coordinate

      like for example { x: 50, y: 50 }

    • to: Coordinate

      like for example { x: 25, y: 25 }

    Returns void

swipeDown

  • swipeDown(percentage?: number): void
  • Swipe down based on a percentage.

    author

    Wim Selles | wswebcreation

    Parameters

    • Default value percentage: number = 1

      between 0 and 1

    Returns void

swipeLeft

  • swipeLeft(percentage?: number): void
  • Swipes left based on a percentage.

    author

    Wim Selles | wswebcreation

    Parameters

    • Default value percentage: number = 1

      between 0 and 1

    Returns void

swipeLeftOnElement

  • swipeLeftOnElement(element: Element): void
  • Swipes left on the {@code element}.

    Parameters

    • element: Element

      to be swiped on

    Returns void

swipeOnPercentage

  • Swipes from coordinate (from) to the new coordinate (to). The given coordinates are percentages of the screen.

    author

    Wim Selles | wswebcreation

    Example

    // This is a swipe to the left
    const from = { x: 50, y:50 }
    const to = { x: 25, y:50 }

    Parameters

    • from: Coordinate

      like for example { x: 50, y: 50 }

    • to: Coordinate

      like for example { x: 25, y: 25 }

    Returns void

swipeRight

  • swipeRight(percentage?: number): void
  • Swipes right based on a percentage.

    author

    Wim Selles | wswebcreation

    Parameters

    • Default value percentage: number = 1

      between 0 and 1

    Returns void

swipeRightOnElement

  • swipeRightOnElement(element: Element): void
  • Swipes right on the {@code element}.

    Parameters

    • element: Element

      to be swiped on

    Returns void

swipeUp

  • swipeUp(percentage?: number): void
  • Swipes up based on a percentage.

    author

    Wim Selles | wswebcreation

    Parameters

    • Default value percentage: number = 1

      between 0 and 1

    Returns void

Select Functions

mobile$

  • Selects one element on mobile platforms in a cross-platform way. Works in the same way as {@link $} in WebdriverIO. Uses {@code UiSelector} on Android and {@code ios predicate} on iOS.

    Parameters

    Returns Element

mobile$$

  • mobile$$(selector: Selector): ElementArray
  • Selects all elements on mobile platforms in a cross-platform way. Works in the same way as {@link $$} in WebdriverIO. Uses {@code UiSelector} on Android and {@code ios predicate} on iOS.

    Parameters

    Returns ElementArray

Generated using TypeDoc