Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IGondolaMobile

Set of Appium extended actions supported by Gondola

Hierarchy

  • IGondolaMobile

Index

Methods

checkAppIsInstalled

  • checkAppIsInstalled(appPackageId: string): void
  • Checks if the specified app is installed. If the specified app is installed, the verify point is considered: Passed; otherwise the test result is: Failed.

    example
    
    gondola.checkAppIsInstalled("com.example.appName);

    Parameters

    • appPackageId: string

      app package name

    Returns void

executeCommand

  • executeCommand(command: string, args?: Array<string | object | number | boolean | undefined>): Promise<any>
  • example
    // get current app activity name
    // full command: adb shell "dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'"
    await gondola.runOnAndroid(async () => {
        const currentAppInfo = await gondola.executeCommand("mobile:shell", [{
            command: "dumpsys",
            args: [
                "window",
                "windows",
                "|",
                "grep",
                "-E",
                "'mCurrentFocus|mFocusedApp'",
            ],
        }]);
        console.log(currentAppInfo);
    });
    
    // get battery info on iOS
    await gondola.runOnIOS(async () => {
        const batteryInfo = await gondola.executeCommand("mobile:batteryInfo", []);
        console.log(batteryInfo);
    });

    Parameters

    • command: string

      command name

    • Optional args: Array<string | object | number | boolean | undefined>

      JSON serializable argument

    Returns Promise<any>

getAllContexts

  • getAllContexts(): Promise<string[]>
  • Gets a list of all available contexts

    example
    
    let allContext: string[] = await gondola.getAllContexts();

    Returns Promise<string[]>

getContext

  • getContext(): Promise<string>
  • Retrieves the current context

    example
    
    let currentContext: string = await gondola.getContext();

    Returns Promise<string>

getCurrentBrowser

  • getCurrentBrowser(): Promise<Client & Browser>
  • Gets the WebDriver browser.

    example
    
    const browser = await gondola.getCurrentBrowser();
    const element = await browser.findElement("accessibility id", "exampleId");
    * ```

    Returns Promise<Client & Browser>

getDeviceScreenSize

  • getDeviceScreenSize(): Promise<RectReturn>
  • Gets device screen size

    example
    
    let screenSize = await gondola.getDeviceScreenSize();

    Returns Promise<RectReturn>

getElementBounds

  • Retrieves an element's boundary.

    example
    
    let bound = await gondola.getElementBounds("~accessibleId");
    let right = bound.left + bound.width;
    let bottom = bound.top + bound.height;

    Parameters

    • element: string | ILocator

      located by accessible id, xpath,... locator

    Returns Promise<IRect>

hideDeviceKeyboard

  • hideDeviceKeyboard(strategy?: undefined | string, key?: undefined | string): void
  • Hides the device keyboard

    experimental

    v1 > Can be changed or removed soon

    Parameters

    • Optional strategy: undefined | string

      (Optional) desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’ or ‘gTapOut’). ‘gTapOut’ only support for IOS

    • Optional key: undefined | string

      (Optional) desired key to use with strategy "pressKey"

    Returns void

runOnAndroid

  • runOnAndroid(options?: any, Function?: Function): void
  • Runs the given function when testing on Android.

    Note: When using the capabilities option, your option must be declared in the gondola config file for it to work.

    example
    
    gondola.runOnAndroid(async () => {
         await gondola.tap("~accessibleId");
         // ...
    });
    
    // Filter can be applied by checking for capabilities. This code only run on Android 7.0
    gondola.runOnAndroid({platformVersion: '7.0'}, () =>{
         // ...
    });
    
    // Capabilities can be checked by a function. In this case , code will be executed only on android >= 6
    gondola.runOnAndroid((cap) => {return cap.platformVersion >= 6}, ()=>{
         // ...
    });

    Parameters

    • Optional options: any

      capabilities use to filter

    • Optional Function: Function

    Returns void

runOnIOS

  • runOnIOS(options?: any, Function?: Function): void
  • Runs the given function when testing on iOS.

    Note: if you're using Appium's Desired Capabilities, you must have the options set in ```gondola.json`` under the helpers->Appium->desiredCapabilities section.

    example
    
    gondola.runOnIOS(async () => {
         await gondola.tap("~accessibleId");
         // ...
    });
    
    // Filter can be applied by checking for capabilities. This code only run on runOnIOS 6.0
    gondola.runOnIOS({platformVersion: '6.0'}, () => {
         // ...
    });
    
    // Capabilities can be checked by a function. In this case , code will be executed only on runOnIOS >= 6
    gondola.runOnIOS((cap) => {return cap.platformVersion >= 6}, () => {
         // ...
    });

    Parameters

    • Optional options: any

      capabilities use to filter

    • Optional Function: Function

      callback function will be executed

    Returns void

scrollIntoView

  • scrollIntoView(element: string | ILocator): Promise<void>
  • Scrolls element into view. > Supports "WEBVIEW" context only

    example
    
    await gondola.scrollIntoView({xpath: "//a"}});

    Parameters

    • element: string | ILocator

      located by CSS|XPath|ILocator.

    Returns Promise<void>

sendDeviceKeyEvent

  • sendDeviceKeyEvent(keyValue: number): void
  • Sends a key event to the device.

    example
    
    gondola.sendDeviceKeyEvent(3);
    experimental

    v1 > Can be changed or removed soon

    Parameters

    Returns void

setPickerValue

  • setPickerValue(element: string | ILocator, value: string | Array<string | undefined>): Promise<void>
  • Selects a scroll picker item or items.
    Supported Android controls:
    - android.widget.DatePicker
    - android.widget.NumberPicker
    Supported iOS controls:
    - XCUIElementTypeDatePicker
    - XCUIElementTypePickerWheel

    experimental

    v1 > For IOS SDK version 12.x, use Xcode 11

    example
    // Single item: pickerElement is a day, month or year that is a child control of a picker
    await gondola.setPickerValue(pickerElement, "item name");
    
    // Multiple items: pickerElement is a picker control. It does not include any child controls.
    await gondola.setPickerValue(pickerElement, ["one", "two", "three"]);
    
    // Multiple items that contain an undefined item: the undefined item will not change
    // and pickerElement is a picker control. It does not include any child controls.
    await gondola.setPickerValue(pickerElement, ["one", undefined, "three"]);
    

    Parameters

    • element: string | ILocator
    • value: string | Array<string | undefined>

    Returns Promise<void>

swipe

  • swipe(element: string | ILocator, offsetX: number, offsetY: number, duration?: undefined | number): void
  • Performs a swipe on an element.

    example
    
    await gondola.swipe("~accessibleId",0, -1000);

    Parameters

    • element: string | ILocator

      located by accessible id, xpath,... ILocator

    • offsetX: number
    • offsetY: number
    • Optional duration: undefined | number

      time in milliseconds to swipe, default value is 1000 ms.

    Returns void

swipeByCoordinates

  • swipeByCoordinates(startX: number, startY: number, offsetX: number, offsetY: number, duration?: undefined | number): void
  • Performs a swipe on the screen.

    example
    
    await gondola.swipeByCoordinates(0, 0, 0, 600);

    Parameters

    • startX: number
    • startY: number
    • offsetX: number
    • offsetY: number
    • Optional duration: undefined | number

      time in milliseconds to swipe, default value is 1000 ms.

    Returns void

switchToContext

  • switchToContext(context: string): Promise<any>
  • Switches to the specified context.

    example
    
    await gondola.switchToContext("NATIVE_APP");

    Parameters

    • context: string

    Returns Promise<any>

tap

  • Taps on a mobile element.

    example
    
    gondola.tap("~accessibleId");
    gondola.tap({id: "buttonId"});
    gondola.tap({
         android: "//com.android.TextView[@text='myLabel']",
         ios: "~myId"
    });

    Parameters

    • element: string | ILocator

      located by accessible id, xpath,... ILocator

    Returns void