• Public
  • Public/Protected
  • All

Interface CommonActionsApi





  • _eval<T>(source: string, ..._args: any[]): Promise<T>
  • This function sends Javascript to the browser which is executed their. you can pass a list of arguments to this script.

    The function is using ThenableWebdriver.executeScript internally.

    All element queries in the _args list (e.g. _div('Hello')) are resolved to WebElements and are available as a HTMLElement in the script

    All _args are available in the arguments array in the script.

    the return value of the JavaScript is returned from this function.

    const windowOuterHeight = await _eval(`return window.outerHeight`);
    // Dispatch a custom Event from a button on the page
    const await _eval(`
       const btn = arguments[0];
       btn.dispatchEvent(new CustomEvent('something-custom'));
    `, _button('Some special Button'))

    Type parameters

    • T


    • source: string

      Javascript code which is executed in the browser

    • Rest ..._args: any[]

      A variadic list of arguments that are passed to Javascript

    Returns Promise<T>


  • Draws a red border around an element on the website.

    This is useful for debugging and demonstrating reasons. Note that the timeout of this highlight will increase the actual execution time of the current step.


    • query: SahiElementQueryOrWebElement | WebElement

      The element to be highlighted

    • Optional timeoutMs: undefined | number

      determine how long the highlight will last (default: 2000)

    Returns Promise<void>


  • _navigateTo(target: string, forceReload?: undefined | false | true, credentials?: undefined | object): Promise<any>
  • Navigates the browser instance to the given URL (also Data URLs are possible).

    // open sakuli.io in the browser
    await _navigateTo("https://sakuli.io");
    // navigate and authenticate on a page with http-basic
    await _navigateTo("https://sakuli.io/fictional-admin", false, {user: 'UserName', password: 'top$ecret'})

    It uses ThenableWebdriver.get() under the hood.


    • target: string

      The URL of the Website to test - Could be any string that can be entered in a browser navigationbar

    • Optional forceReload: undefined | false | true

      Forces the page to reload after it has been loaded - it is a relict of Sahi. Default: false

    • Optional credentials: undefined | object

      If a site requires "Http-Basic-Authentication" you can pass the credentials here

    Returns Promise<any>



  • _wait(millis: number, expression?: undefined | function): Promise<void>
  • Wait for a maximum of the given timeout. It's also possible to pass an expression function which will be evaluated during the waiting.

    // just waiting 10 seconds until proceeding
    await _wait(10000);
    // Will wait at most 5 seconds until a submit button with the text "Buy now" is visible
    await _wait(5000, () => _isVisible(_submit('Buy Now')));


    • millis: number

      Maximum amount of time to be waiting (in milliseconds)

    • Optional expression: undefined | function

      An optional function which will abort the wait when it returns a truthy value

    Returns Promise<void>