Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface LegacyApi

Hierarchy

Index

Properties

Methods

Properties

$includeFolder: string

A relic from Sahi, just defined to ensure backward compatibility

Application: Type<ThenableApplication>
Environment: Type<ThenableEnvironment>
Key: typeof Key
Logger: Logger
MouseButton: typeof MouseButton
Region: Type<ThenableRegion>
TestCase: Type<TestCase>
context: TestExecutionContext

The current TestExecutionContext provided by Sakuli runtime this is usually not needed in a Testcase.

driver: ThenableWebDriver

Instance of ThenableWebDriver. Can execute any native method of webdriver. It's not recommended to use it in a testcase.

Methods

  • _abbr(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a area element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: area

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _above(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located above the center of the anchor element on the y axis
    • The relational element is vertically aligned with the anchor element
    example
    +----+
    | 3 |
    +----+
    : +----+
    : | 2 |
    : +----+
    +----+
    | 1 |
    +----+

    In this case element 2 is "above" element 1 and element 3 is also "above" element 1, but element 3 is not "above" element 2 as they do not align vertically.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _activeElement(): SahiElementQueryOrWebElement
  • _areEqual(query1: SahiElementQueryOrWebElement, query2: SahiElementQueryOrWebElement): Promise<boolean>
  • Checks if two queries resolves to the same element.

    example

    Assume this HTML-snippet:

    <ul>
    <li>entry</li>
    <li>entry</li>
    </ul>

    Test the equality of two elements:

    // _listItem("entry") will fetch the first list item
    const equal = await _areEqual(_listItem(0), _listItem("entry")) // -> true
    const notEqual = await _areEqual(_listItem(1), _listItem("entry")) // -> false

    Parameters

    • query1: SahiElementQueryOrWebElement
    • query2: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _area(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a area element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: area

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _article(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a article element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: article

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _aside(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a aside element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: aside

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _assert(condition: Promise<boolean>, message?: string): Promise<void>
  • _assertContainsText(expected: string, element: SahiElementQueryOrWebElement, message?: string): Promise<void>
  • _assertEqual(expected: any, actual: any, message?: string): Promise<void>
  • _assertEqualArrays(expected: any[], actual: any[], message?: string): Promise<void>
  • Basically the same as {@link AssertionApi._assertEqual} but only excepts arrays as èxpected and actual values.

    Parameters

    • expected: any[]
    • actual: any[]
    • Optional message: string

    Returns Promise<void>

  • _assertExists(element: SahiElementQueryOrWebElement, message?: string): Promise<void>
  • _assertFalse(condition: Promise<boolean>, message?: string): Promise<void>
  • _assertNotContainsText(expected: string, element: SahiElementQueryOrWebElement, message?: string): Promise<void>
  • _assertNotEqual(expected: any, actual: any, message?: string): Promise<void>
  • _assertNotExists(element: SahiElementQueryOrWebElement, message?: string): Promise<void>
  • _assertNotNull(value: any, message?: string): Promise<void>
  • _assertNotTrue(condition: Promise<boolean>, message?: string): Promise<void>
  • Alias for {@link AssertionApi._assertFalse}

    Parameters

    • condition: Promise<boolean>
    • Optional message: string

      If the exception from this assertion is not handled, Sakuli will print and log this message.

    Returns Promise<void>

  • _assertNull(value: any, message?: string): Promise<void>
  • _assertTrue(condition: Promise<boolean>, message?: string): Promise<void>
  • Alias for {@link AssertionApi._assert}

    Parameters

    • condition: Promise<boolean>
    • Optional message: string

      If the exception from this assertion is not handled, Sakuli will print and log this message.

    Returns Promise<void>

  • _blockquote(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a blockqoute element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: blockqoute

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _blur(query: SahiElementQueryOrWebElement): Promise<void>
  • Fetches an element and performs the native .blur() in the browser. That means that this element will lose the focus-state.

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<void>

    Resolves when browser-script finished

  • _bold(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a bold element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: b

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _button(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a button by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: button

    example

    Assuming the following HTML-snippet

    <button>Click Me</button>
    

    Invoking a click on this button:

    await _click(_button('Click Me'));
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _byClassName(clsName: string, tagName: string): SahiElementQueryOrWebElement
  • Fetches an element of TagName with clsName in it's classList attribute

    Based on CSS selector: tagName.clsName

    example


    Assuming this HTML-snippet:

        <p class="leading class2">Lorem ipsum</p>
    

    Can be highlighted like this:

       // will highlight the paragraph above
    await _highlight(_byClassName('leading', 'p'));

    Parameters

    • clsName: string
    • tagName: string

    Returns SahiElementQueryOrWebElement

  • _byId(id: string): SahiElementQueryOrWebElement
  • Fetches an element by it's id attribute. If the id of an element i known and somehow stable in the dom (not generated by an CMS for example) this is the recommended way to query an element because it is the fastest.

    Parameters

    • id: string

      id of the element. Like document.getElementById(id)

    Returns SahiElementQueryOrWebElement

  • _byText(text: string, tagName: string): SahiElementQueryOrWebElement
  • _byXPath(xPath: string): SahiElementQueryOrWebElement
  • Fetches an element by a xPath-expression on the current webpage.

    example

    Assuming the following HTML-snippet:

        <ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    </ul>

    Fetching the second item from the list:

        const item2 = await _fetch(_byXPath('/ul/li[2]'));
    

    Parameters

    • xPath: string

    Returns SahiElementQueryOrWebElement

  • _canvas(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a canvas element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: canvas

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _cell(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a table-data element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: td

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _check(query: SahiElementQueryOrWebElement): Promise<void>
  • _checkbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a checkbox field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="checkbox"]

    example

    Assuming the following HTML-snippet:

    <label>
    <input type="checkbox" name="like-pizza">
    <span>Like Pizza?</span>
    </label>

    Checking the field with [_check]{@link MouseActionApi._check}:

    await _check(_checkbox('like-pizza'));
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _click(query: SahiElementQueryOrWebElement, combo?: string | ClickOptions, options?: ClickOptions): Promise<void>
  • _click simulates a user's click on the given element.

    example

    _click(_button("Click Me"));
    _click(_button("Click Me"), "CTRL"); // clicks with CTRL key pressed
    _click(_button("Click Me"), "CTRL|SHIFT"); // clicks with CTRL and SHIFT keys pressed
    _click(_button("Click Me"), {force: true}); // clicks without validation
    _click(_button("Click Me"), "CTRL", {force: true}); //clicks with CTRL without validation

    Parameters

    • query: SahiElementQueryOrWebElement

      query to the Element to click on

    • Optional combo: string | ClickOptions

      Optional combo key(s): can be CTRL, SHIFT, ALT or META; Can also be two or more keys together like "CTRL|SHIFT"

    • Optional options: ClickOptions

      disables validations prior to the click action to enforce clicks where an element e.g. is covered

    Returns Promise<void>

    Resolves after the click is invoked, doesn't wait for further actions on the website which are possibly invoked after the click

  • _code(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a code element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: code

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _collect(accessorApiMethod: AccessorFunctions, identifier: AccessorIdentifier, ...relations: SahiRelation[]): Promise<WebElement[]>
  • Collects all specified elements

    example

    Assuming the following HTML-snippet:

        <div class="city">Los Angeles</div>
    <div class="city>Berlin</div>

    Highlights the div containing second city:

        const cities = await _collect('_div', 'city');

    await _highlight(cities[1]);

    Parameters

    • accessorApiMethod: AccessorFunctions
    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns Promise<WebElement[]>

  • _contains(parent: SahiElementQueryOrWebElement, child: SahiElementQueryOrWebElement): Promise<boolean>
  • Check if a parent element contains a child element.

    example

    Assume the following HTML-snippet:

    <div id="parent">
    <div id="child-a"></div>
    <div id="child-b"></div>
    </div>

    Check if an element is the contained within another

    await _contains(_div('parent'), _div('child-b')) // -> true
    await _contains(_div('child-a'), _div('child-b')) // -> false

    Parameters

    • parent: SahiElementQueryOrWebElement
    • child: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _containsHTML(query: SahiElementQueryOrWebElement, html: string): Promise<boolean>
  • Compares the .innerHTML of an element with the given html string. Both .innerHTML and the snippet are unified using the html function from common-tags library.

    example

    Assume the following HTML-snippet:

    <div id="d1" style="background-color: yellow"><i>Formatted</i> Text</div>
    

    Check if an element contains certain HTML:

    await _containsHTML(_div(0), '<i>Formatted</i>'); // -> true
    await _containsHTML(_div(0), 'Text'); // -> true
    await _containsHTML(_div(0), '<i>Formatted</i> Text'); // -> true
    await _containsHTML(_div(0), '<i>.*</i>'); // -> true
    await _containsHTML(_div(0), 'Formatted Text'); // -> false
    await _containsHTML(_div(0), 'Non existent'); // -> false

    Parameters

    • query: SahiElementQueryOrWebElement
    • html: string

    Returns Promise<boolean>

  • _containsText(query: SahiElementQueryOrWebElement, text: string): Promise<boolean>
  • Checks if the displayed text of the element contains the given text. The text parameter is turned into an RegExp object before performing the check.

    example

    Assume following HTML-snippet:

    <p ="intro">
    Lorem ipsum dolor sit amet. consetetur sadipscing elitr
    </p>
    <!-- Inner HTML-tags are stripped -->
    <div>Hello <i>World</i></div>
    <div id="pending-request">
    There are 5 pending request
    </div>

    Check if a element contains certain text:

    const containsIpsumDolor = await _containsText(_paragraph('intro'), 'ipsum dolor') // -> true
    const containsYpsumDolor = await _containsText(_paragraph('intro'), 'ypsum dolor') // -> false

    const containsText = await _containsText(_div(0), 'Hello World'); // -> true

    const probablyDynamicText = await _containsText(_div('pending-request'), "There are . pending requests"); // -> true

    Parameters

    • query: SahiElementQueryOrWebElement
    • text: string

    Returns Promise<boolean>

  • _count(accessorApiMethod: AccessorFunctions, identifier: AccessorIdentifier, ...relations: SahiRelation[]): Promise<number>
  • Counts all specified elements

    example

    Assuming the following HTML-snippet:

        <div class="city">Los Angeles</div>
    <div class="city>Berlin</div>

    Logs the city count into sakuli.log:

        const cityCount = await _count('_div', 'city');

    Logger.logInfo(`${cityCount} cities found`);

    Parameters

    • accessorApiMethod: AccessorFunctions
    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns Promise<number>

  • _dDesc(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a definition-description element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: dd

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _dList(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a definition-list element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: dl

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _dTerm(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a definition-term element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: dt

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _datebox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a date field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="date"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="date" name="date-input" />
    

    Setting the value of this field:

       await _setValue(_datebox('date-input'), '2019-07-22')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _datetimebox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a datetime field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="datetime"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="datetime" name="date-input" />
    

    Setting the value of this field:

       await _setValue(_datetimebox('date-input'), '2019-07-22T19:30')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _datetimelocalbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a datetime-local field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="datetime-local"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="datetime-local" name="date-input" />
    

    Setting the value of this field:

       await _setValue(_datetimelocalbox('date-input'), '2019-07-22T19:30')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _details(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a details element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: details

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _div(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a div element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: div

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _dragDrop(eSource: SahiElementQueryOrWebElement, eTarget: SahiElementQueryOrWebElement): Promise<void>
  • Performs a mouse down on eSource, than moves the mouse to the position of element eTarget and releases the mouse button at this position.

    This implementation uses Webdriver actions which does not always behave as expected.

    For a more reliable experience ThenableRegion.dragAndDropTo is recommended.

    Parameters

    • eSource: SahiElementQueryOrWebElement
    • eTarget: SahiElementQueryOrWebElement

    Returns Promise<void>

  • _dragDropXY(q: SahiElementQueryOrWebElement, x: number, y: number, $isRelative?: boolean): Promise<void>
  • Performs a mouse down on eSource, than moves the mouse to the position P(x,y) in the browsers' viewport and releases the mouse button at this position.

    This implementation uses Webdriver actions which does not always behave as expected.

    For a more reliable experience ThenableRegion.dragAndDropTo is recommended.

    Parameters

    • q: SahiElementQueryOrWebElement
    • x: number
    • y: number
    • Optional $isRelative: boolean

    Returns Promise<void>

  • _dynamicInclude(): Promise<void>
  • _emailbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a email field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="email"]

    example

    Assuming the following HTML-snippet:

       <input type="email" name="mail-input" />
    

    Setting the value of this field:

       await _setValue(_emailbox('mail-input'), 'do-not-spam@sakuli.io')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _embed(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a embed element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: embed

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _emphasis(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches an emphasis element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: em

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _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.

    example
    const windowOuterHeight = await _eval(`return window.outerHeight`);
    
    example
    // 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 = any

    Parameters

    • 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>

  • _exists(query: SahiElementQueryOrWebElement): Promise<boolean>
  • Resolves to true / false when the element can be found in the DOM or not.

    example

    Assume this HTML-snippet:

    <div>Hello</div>
    

    Determine if an element is present in the current DOM:

    const present = await _exists(_div("Hello")); // -> true
    const absent = await _exists(_div("World")); // -> false

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _fetch(query: SahiElementQueryOrWebElement): Promise<WebElement>
  • _fieldset(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a fieldset element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: fieldset

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _figcaption(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a figcaption element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: figcaption

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _figure(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a figure element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: figure

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _file(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a file input by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="file"]

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _focus(query: SahiElementQueryOrWebElement): Promise<void>
  • Fetches an element and performs the native .focus() method in the browser. When _focus is performed on an <input> element, it will be automatically scrolled into the viewport by the browser.

    Note that not all elements will get an actual focus in the browser. Usually links and user-controls (e.g. <input>, <textarea>, <select>...) can gain focus.

    Parameters

    • query: SahiElementQueryOrWebElement

      Query or concrete WebElement

    Returns Promise<void>

    Resolves when browser-script finished

  • _font(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a font element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: font

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _footer(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a footer element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: footer

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _frame(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a frame element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: frame

    deprecated

    Frames are even deprecated in HTML itself. Anyway some legacy pages are still using this technology. To access elements in a frame, the same method as described for [_iframe]{@link AccessorApi._iframe} can be used.

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _getAttribute(query: SahiElementQueryOrWebElement, name: string): Promise<string>
  • Retrieves the value of an element attribute.

    example

    Assume this HTML-snippet:

    <div
    data-testid="foo-element"
    class="widget primary"
    >Foo bar</div>

    Accessing the values of div attributes:

    const dataTestId = await _getAttribute(_div(/Foo bar/), 'data-testid'); // -> "foo-element"
    const classNames = await _getAttribute(_div(/Foo bar/), 'class'); // -> "widget primary"

    Parameters

    • query: SahiElementQueryOrWebElement
    • name: string

    Returns Promise<string>

  • _getCellText(query: SahiElementQueryOrWebElement): Promise<string>
  • _getFetchTimeout(): number
  • _getOptions(query: SahiElementQueryOrWebElement, value?: "value"): Promise<string[]>
  • Finds all option elements within the queried element and resolves to an array with all visible texts of the options. If the parameter value is set to "value" it will resolve to an array with all option values.

    example

    Assume this HTML-snippet:

    <select name="answers">
    <option value="a-yes">Yes</option>
    <option value="a-no">No</option>
    <option value="a-maybe">Maybe</option>
    </select>

    Accessing either to displayed text or the actual values of the options:

    const optionTexts = await _getOptions(_select('answers')); // -> ['Yes', 'No', 'Maybe']
    const optionValues = await _getOptions(_select('answers'), "value"); // -> ['a-yes', 'a-no', 'a-maybe']

    Parameters

    • query: SahiElementQueryOrWebElement
    • Optional value: "value"

    Returns Promise<string[]>

  • _getSelectedText(query: SahiElementQueryOrWebElement): Promise<string>
  • Retrieves the text content of the selected option within the select element.

    example

    Assume this HTML-snippet:

    <select name="answers">
    <option value="a-yes">Yes</option>
    <option value="a-no">No</option>
    <option selected="selected" value="a-maybe">Maybe</option>
    <!-- Selected attribute is also set if the user (or Sakuli) selects the option in the browser -->
    </select>

    Accessing either the displayed text or the actual value of the options:

    const selectedOptionText = await _getSelected(_select('answers')); // -> 'a-maybe'
    

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<string>

  • _getSelectionText(): Promise<string>
  • Retrieves the selection from a user in the current document as a string. This is most likely the text what will set to the clipboard if a user copies the selection.

    Returns Promise<string>

  • _getText(query: SahiElementQueryOrWebElement): Promise<string>
  • Gets the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace. It uses WebElement.getText() method internally.

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<string>

  • _getValue(query: SahiElementQueryOrWebElement): Promise<string>
  • Retrieves the actual value from the value attribute of an [Element or Query]{@link SahiElementQueryOrWebElement}.

    example

    Assume this HTML-snippet:

    <input type="text" name="with-value" value="Hello World" />
    <div id="without-value"></div>

    Accessing the value of [value]

    const valueFromInput = await _getValue(_textbox('with-value')); // -> "Hello World"
    const noValue = await _getValue(_div('without-value')); // -> undefined

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<string>

  • _header(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a header element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: header

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading1(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h1

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading2(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h2

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading3(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h3

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading4(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h4

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading5(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h5

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _heading6(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a heading element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: h6

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _hidden(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a hidden field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="hidden"]

    example

    Assuming the following HTML-snippet:

       <input type="hidden" name="hidden-input" />
    

    Setting the value of this field:

       await _setValue(_hidden('hidden-input'), 'some data')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _highlight(query: SahiElementQueryOrWebElement, timeoutMs?: number): Promise<void>
  • 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.

    Parameters

    • query: SahiElementQueryOrWebElement

      The element to be highlighted

    • Optional timeoutMs: number

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

    Returns Promise<void>

  • _hr(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a horizontal-ruler element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: hr

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _iframe(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a iframe element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: iframe

    example

    Accessing a Iframe: ``

    <!-- embeded.html -->
    <button>Button in a frame</button>

    <!-- page.html -->
    <iframe src="embeded.html" />

    Sakuli can also access contents from an Iframe using the WebDriver-instance

    await _navigateTo('page.html'); // 1.
    const iFrame = await _fetch(_iframe(0)); // 2.
    await driver.switchTo().frame(iFrame); // 3.
    await _click(_button('Button in a frame')); // 4.
    await driver.switchTo().defaultContent();
    1. Assuming that Sakuli is navigated to page that contains an iframe
    2. Fetch an instance of seleniums WebElement using [_fetch]{@link FetchApi._fetch}
    3. Using seleniums switchTo().frame() to change the context to the iframe
    4. Now elements within the iframe page are accessible
    5. Switching back to the "main-frame"

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _image(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches an image by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: img

    example

    Assuming the following HTML-snippet:

    <img src="funny-cat.gif" title="" />
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _imageSubmitButton(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a image button by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="image"]

    example

    Assuming the following HTML-snippet:

    <form>
    <label>User: <input type="text" name="username" /></label>
    <label>Password: <input type="password" name="password" /></label>
    <input type="image" src="cool-button.png" name="login" />
    </form>

    Submitting the form with a [_click]{@link MouseActionApi._click}

    await _click(_imageSubmitButton('login'));
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _in(anchor: SahiElementQueryOrWebElement): SahiRelation
  • Creates a relation that specifies elements inside the anchor element.

    example


    Assuming this HTML-snippet:

    <b>something</b>
    <div id="div1">
    <b>something</b>
    </div>

    The following expression returns the second bold element.

    await _bold("something", _in(_byId("div1")));
    

    Parameters

    • anchor: SahiElementQueryOrWebElement

    Returns SahiRelation

  • _isChecked(query: SahiElementQueryOrWebElement): Promise<boolean>
  • Checks if the element has an attribute checked. This is useful for checkboxes or radio inputs.

    example

    Assume this HTML-snippet:

       <input type="radio" name="payment" value=debit-card" />
    <input type="radio" name="payment" value="cash" />

    Checks if a radio input is checked or not:

    const checked = await _isChecked(_radio(0)); // -> true
    const notChecked = await _isChecked(_radio(1)); // -> false

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _isEnabled(query: SahiElementQueryOrWebElement): Promise<boolean>
  • Checks if an element is enabled. An element is considered as enabled when it has no disabled attribute set.

    example

    Assume this HTML-snippet:

    <input type="text" id="enabled-input" />
    <input type="text" disabled id="disabled-input" />

    Check if the inputs are enabled:

    const enabled = await _isEnabled(_textbox('enabled-input')); // -> true
    const disabled = await _isEnabled(_textbox('disabled-input')); // -> false

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _isVisible(query: SahiElementQueryOrWebElement): Promise<boolean>
  • Tests if this element is currently displayed. Using a timeout of maximum one second. If a longer timeout is needed, {@link ActionApi._wait} can be used. It uses WebElement.isDisplayed internally.

    example

    Assume this HTML-snippet:

    <div>Hello World</div>
    <div style="display: none">Ninja Element</div>

    Testing the visibility of the elements:

    const visible = await _isVisible(_div("Hello World")) // -> true
    const invisible = await _isVisible(_div("Ninja Element")) // -> false

    // Waits at most 5 seconds until element is visible

    await _wait(5000, () => _isVisible(_div('Hello World')));

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<boolean>

  • _italic(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a italic element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: i

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _keyDown(query: SahiElementQueryOrWebElement, charInfo: CharInfo, combo?: string): Promise<void>
  • Invokes a single keydown event on the given element. This is useful if you want to invoke a certain event which relies on the keydown event. In most cases it has to be used together with {@link KeyboardActionsApi._keyUp}

    Parameters

    • query: SahiElementQueryOrWebElement
    • charInfo: CharInfo
    • Optional combo: string

      Optional combo key(s): can be CTRL, SHIFT, ALT or META; Can also be two or more keys together like "CTRL|SHIFT"

    Returns Promise<void>

  • _keyPress(query: SahiElementQueryOrWebElement, charInfo: CharInfo, combo?: string): Promise<void>
  • Performs a single keystroke ('keypress'-event) on the element.

    example

    Performing CTRL+s on an (imaginary) web-based word-processor element:

    await _keyPress(_byId('word-processor-canvas'), 's', 'CTRL')
    

    Parameters

    • query: SahiElementQueryOrWebElement
    • charInfo: CharInfo
    • Optional combo: string

      Optional combo key(s): can be CTRL, SHIFT, ALT or META; Can also be two or more keys together like "CTRL|SHIFT"

    Returns Promise<void>

  • _keyUp(query: SahiElementQueryOrWebElement, charInfo: CharInfo): Promise<void>
  • Invokes a single keyup event with the given element. This is only useful when {@link KeyboardActionsApi._keyDown} is invoked previously. Some WebDrivers like Firefox will not trigger any event if there was no keypress before.

    Parameters

    • query: SahiElementQueryOrWebElement
    • charInfo: CharInfo

    Returns Promise<void>

  • _label(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a label element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: label

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _leftOf(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located left of the center of the anchor element on the x axis
    • The relational element is horizontally aligned with the anchor element
    +----+
    | 1 |
    +----+ ~~~~~~~~~ +----+
    +----+ ~ | 3 |
    | 2 | +----+
    +----+

    In this case element 1 and element 2 are "left of" element 3, but element 1 is not "left of" element 2 as they do not align horizontally.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _leftOrRightOf(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located left or right of the center of the anchor element on the x axis
    • The relational element is horizontally aligned with the anchor element
    +----+
    | 1 |
    +----+ ~~~~~~~~~ +----+
    | 3 | ~ +----+
    +----+ | 2 |
    +----+ +----+
    | 4 |
    +----+

    In this case element 1 and element 2 are "left or right of" element 3, but element 4 is not "left or right of" element 3 as they do not align horizontally.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _link(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a anchor / link element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: a

    example

    Assuming the following HTML-snippet:

    <nav>
    <a href="/home">Home</a>
    <a href="/home">About</a>
    </nav>

    Following the "About" link with [_click]{@link MouseActionApi._click}

    await _click(_link('About'))
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _list(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches an unordered list element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: ul

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _listItem(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a list-item element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: li

    example

    Assuming the following HTML-snippet:

    <ul>
    <li>Pizza</li>
    <li>Burger</li>
    <li lang="de">Bratwurst</li>
    </ul>
    const lang = await _getAttribute(_listItem('Bratwurst'), 'lang'); // -> 'de'
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _main(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a main element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: main

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _map(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a map element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: map

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _mark(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a mark element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: mark

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _monthbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a month field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="month"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="month" name="month-input" />
    

    Setting the value of this field:

       await _setValue(_monthbox('month-input'), '2019-07')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _mouseDown(query: SahiElementQueryOrWebElement, isRight?: boolean, combo?: string): Promise<void>
  • _mouseOver(query: SahiElementQueryOrWebElement, combo?: string): Promise<void>
  • Invokes a mouse over on the queried element. Can be combined with a key combo.

    Parameters

    • query: SahiElementQueryOrWebElement
    • Optional combo: string

      Optional combo key(s): can be CTRL, SHIFT, ALT or META; Can also be two or more keys together like "CTRL|SHIFT"

    Returns Promise<void>

  • _mouseUp(query: SahiElementQueryOrWebElement, isRight?: boolean, combo?: string): Promise<void>
  • _nav(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a nav element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: nav

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _navigateTo(target: string, forceReload?: boolean, credentials?: { password: string; user: string }): Promise<any>
  • Navigates the browser instance to the given URL (also Data URLs are possible).

    example
    // 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.

    Parameters

    • target: string

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

    • Optional forceReload: boolean

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

    • Optional credentials: { password: string; user: string }

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

      • password: string
      • user: string

    Returns Promise<any>

  • _near(anchor: SahiElementQueryOrWebElement): SahiRelation
  • Creates a relation which returns the given element nearest (distance within the DOM tree) to the anchor

    example

    Assuming the following HTML-snippets

    <div>
    <p id="elem0">elem</p>
    <p id="elem1">elem</p>
    <p id="anchor"></p>
    </div>
    <div>
    <div>
    <p id="elem0">elem</p>
    <p id="elem1">elem</p>
    </div>
    <p id="anchor"></p>
    </div>

    The following query will return in both cases the element with id="elem0"

    _paragraph("elem", _near(_paragraph("anchor"));
    

    Parameters

    • anchor: SahiElementQueryOrWebElement

    Returns SahiRelation

  • _numberbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a number field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="number"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="number" name="number-input" />
    

    Setting the value of this field:

       await _setValue(_numberbox('number-input'), 5)
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _object(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a object element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: object

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _option(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches an option element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: select

    example

    Assuming the following HTML-snippet

    <select name="preferred-drink">
    <option value="water" selected>Water</option>
    <option value="wine">Wine</option>
    <option value="beer">Beer</option>
    </select>

    Detect if an option is visible with [_isVisible]{@link FetchApi._isVisible}

    await _isVisible(_option('Wine')); // -> false
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _pageIsStable(timeout?: number, interval?: number): Promise<boolean>
  • Continuously fetches the page source and checks for DOM changes. Will be repeated every $timeout milliseconds until either the DOM does no longer change or $timeout is reached

    example
    // Wait for a stable DOM with default timeout and interval, continue test execution if it does not stabilize within timeout
    await _pageIsStable();

    // Wait for a stable DOM with custom timeout and default interval, continue test execution if it does not stabilize within timeout
    await _pageIsStable(5000);

    // Wait for a stable DOM with custom timeout and custom interval, continue test execution if it does not stabilize within timeout
    await _pageIsStable(5000, 100);

    // Wait for a stable DOM, stop test execution if it does not stabilize within timeout
    await _assertTrue(_pageIsStable(5000, 100));

    Parameters

    • Optional timeout: number

      Maximum timout in ms to wait for DOM stabilization. Default: 2000 ms

    • Optional interval: number

      Interval between stability checks in ms. Default: 200 ms

    Returns Promise<boolean>

  • _paragraph(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a paragraph element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: p

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _parentCell(q: SahiElementQueryOrWebElement, occurrence?: number): Promise<SahiElementQueryOrWebElement>
  • Fetches the HTML-table-cell (with tag td), if the element specified by q is its child. If occurrence is set to n, the n-th parent table-cell out of the hierarchy of given elements parents, will be returned. occurrence defaults to 1, which is the immediate parent.

    example

    Assuming this HTML-snippet:

    <td>
    <div>text</div>
    </td>

    The folliwing query returns the <td> element.

    await _parentCell(_div("text"));
    

    Parameters

    • q: SahiElementQueryOrWebElement
    • Optional occurrence: number

    Returns Promise<SahiElementQueryOrWebElement>

  • _parentNode(q: SahiElementQueryOrWebElement, tagName: string, occurrence?: number): Promise<SahiElementQueryOrWebElement>
  • Fetches an element with tagName that encloses the anchor element q. If occurrence is set to n, the n-th parent of the given element will be returned. occurrence defaults to 1, which is the immediate parent.

    example

    Assuming this HTML-snippet:

    <div>
    <div>something else</div>
    <div id="target">
    something something
    <section>
    <div>
    <b id="anchor">something</b>
    </div>
    </section>
    </div>
    </div>

    The following query returns the element with id "target".

    await _parentNode(_byId("anchor"), "div", 2);
    

    Note: Exits with an error if the occurence parameter is higher than the number of elements with tag tagName in the hierarchy above the anchor element q.

    Parameters

    • q: SahiElementQueryOrWebElement
    • tagName: string
    • Optional occurrence: number

    Returns Promise<SahiElementQueryOrWebElement>

  • _parentRow(q: SahiElementQueryOrWebElement, occurrence?: number): Promise<SahiElementQueryOrWebElement>
  • Fetches the HTML-table-row if it is a parent of the element specified by q. If occurrence is set to n, the n-th parent table-row out of the hierarchy of given elements parents, will be returned. occurrence defaults to 1, which is the immediate parent.

    example

    Assuming this HTML-snippet:

    <tr>
    <td>
    <div>text</div>
    </td>
    </tr>

    The folliwing query returns the <tr> element.

    await _parentRow(_div("text"));
    

    Parameters

    • q: SahiElementQueryOrWebElement
    • Optional occurrence: number

    Returns Promise<SahiElementQueryOrWebElement>

  • _parentTable(q: SahiElementQueryOrWebElement, occurrence?: number): Promise<SahiElementQueryOrWebElement>
  • Fetches the HTML-table if it is a parent of the element specified by q. If occurrence is set to n, the n-th parent table out of the hierarchy of given elements parents, will be returned. occurrence defaults to 1, which is the immediate parent.

    example

    Assuming this HTML-snippet:

    <table>
    <tr>
    <td>
    <div>text</div>
    </td>
    </tr>
    </table>

    The folliwing query returns the <table> element.

    await _parentTable(_div("text"));
    

    Parameters

    • q: SahiElementQueryOrWebElement
    • Optional occurrence: number

    Returns Promise<SahiElementQueryOrWebElement>

  • _password(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a password field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="password"]

    example

    Assuming the following HTML-snippet:

       <input type="password" name="password-input" />
    

    Setting the value of this field:

       await _setValue(_password('password-input'), "$ecret")
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _position(query: SahiElementQueryOrWebElement): Promise<[number, number]>
  • Returns a tuple describing an element's location, in pixels relative to the document element.

    example

    Assuming a modal overlay element at x: 300 and y: 400

    const [x,y] = await _position(_div('modal')) // -> [300, 400];
    

    Parameters

    • query: SahiElementQueryOrWebElement

    Returns Promise<[number, number]>

  • _preformatted(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a preformat element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: pre

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _radio(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a radio field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="radio"]

    example

    Assuming the following HTML-snippet:

    <h2>Prefered Drink?</h2>
    <label>
    <span>Water</span>
    <input type="radio" name="drink" value="water" />
    </label>
    <label>
    <span>Wine</span>
    <input type="radio" name="drink" value="wine" />
    </label>
    <label>
    <span>Beer</span>
    <input type="radio" name="drink" value="beer" />
    </label>

    Checking the field with [_click]{@link MouseActionApi._click}:

    await _click(_radio(1)); // Selects 'Wine'
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _rangebox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a range field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="range"]

    example

    Assuming the following HTML-snippet:

       <input type="range" name="range-input" />
    

    Setting the value of this field:

       await _setValue(_rangebox('range-input'), 5)
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _removeFocus(query: SahiElementQueryOrWebElement): Promise<void>
  • _reset(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a reset button by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="reset"]

    example

    Assuming the following HTML-snippet:

    <form>
    <label>Name: <input type="text" name="username" /></label>
    <label>Street: <input type="text" name="street" /></label>
    <label>Post code: <input type="text" name="postcode" /></label>
    <button type="reset">Clear</button>
    <button type="submit">Save</button>
    </form>

    Clearing the form with a [_click]{@link MouseActionApi._click}

    await _click(_reset('Clear'));
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _rightClick(query: SahiElementQueryOrWebElement, combo?: string): Promise<void>
  • Performs a right click on the queried element. Can be combined with a key combo.

    Parameters

    • query: SahiElementQueryOrWebElement
    • Optional combo: string

      Any combo key: can be "CTRL", "SHIFT", "ALT" or "META"; Can also be two or more keys together like "CTRL|SHIFT"

    Returns Promise<void>

  • _rightOf(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located right of the center of the anchor element on the x axis
    • The relational element is horizontally aligned with the anchor element
    +----+
    | 1 |
    +----+ ~~~~~~~~~ +----+
    +----+ ~ | 3 |
    | 2 | +----+
    +----+

    In this case element 3 is "right of" element 1 and element 2, but element 2 is not "right of" element 1 as they do not align horizontally.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _row(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a table-row element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: tr

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _rte(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a iframe element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: iframe

    deprecated

    This accessor was used in Sahi to access rich-text-editors that were based on iframes. Nowadays the most rich-text / WYSIWYG editors are implemented using HTML and JavaScript within the page were they are displayed.

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _rteWrite(query: SahiElementQueryOrWebElement, content: string): Promise<void>
  • _searchbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a search field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="search"]

    example

    Assuming the following HTML-snippet:

       <input type="search" name="search-input" />
    

    Setting the value of this field:

       await _setValue(_searchbox('search-input'), 'sakuli')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _section(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a section element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: section

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _select(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a select element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: select

    example

    Assuming the following HTML-snippet

    <select name="preferred-drink">
    <option value="water">Water</option>
    <option value="wine">Wine</option>
    <option value="beer">Beer</option>
    </select>

    Change the selected option with [_setSelected]{@link MouseActionApi._setSelected}

    await _setSelected(_select('preferred-drink'), 'beer');
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _setFetchTimeout(timeOutMs: number): void
  • Sets the maximum time Sakuli will try to find an element on dom.

    Parameters

    • timeOutMs: number

      Timeout in milliseconds

    Returns void

  • _setSelected(query: SahiElementQueryOrWebElement, optionToSelect: string | number | string[] | number[], isMultiple?: boolean): Promise<void>
  • Sets the options within a <select> element. Selection can be done by the actual values of an option or its zero-based element index.

    This action will invoke a click on the option element which means that the selected state is not enforced. If an option is already selected, it will be unselected.

    example

    Assume this HTML-snippet:

    <select multiple="multiple" name="cities">
    <option value="muc">Munich</option>
    <option value="vie">Vienna</option>
    <option value="dus">Dusseldorf</option>
    </select>
    await _setSelected(_select('cities'), 'vie') // -> select the option Vienna
    await _setSelected(_select('cities'), 0) // -> select the option Dusseldorf

    Parameters

    • query: SahiElementQueryOrWebElement
    • optionToSelect: string | number | string[] | number[]
    • Optional isMultiple: boolean

    Returns Promise<void>

  • _setValue(query: SahiElementQueryOrWebElement, value: string): Promise<void>
  • Sets a value on an <input /> field.

    It will clear the existing value from the input before:

    • It will send each character from the value string to the input with an delay of 10 ms using .sendKeys. This ensures that components which rely on key-events (like keyup or keydown) will behave as expected on the page.

    • When .sendKeys fails, _setValue will try to set the value attribute of the dom element.

    example

    Assume the following HTML-snippet:

    <form>
    <input type="text" name="username"/>
    <input type="password" name="password" />
    </form>

    _setValue can be used to enter login information:

    await _setValue(_textbox('username'), 'IamGroot');
    await _setValue(_password('password'), '$secret');

    Parameters

    • query: SahiElementQueryOrWebElement
    • value: string

    Returns Promise<void>

  • _span(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a span element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: span

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _strong(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a strong element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: strong

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _style(query: SahiElementQueryOrWebElement, attr: string): Promise<string>
  • Styles in HTML elements are calculated by the browser based on various CSS rules. _style returns the computed style that is finally applicable to the element. If the element inherits the named style from its parent, the parent will be queried for its value. Where possible, color values will be converted to their hex representation (e.g. #00ff00 instead of rgb(0, 255, 0)).

    Accessing the style directly as an attribute will not return a computed style. Always use _style instead.

    Warning: A proper assertion will be difficult as some browser may interpret it differently.

    Parameters

    • query: SahiElementQueryOrWebElement
    • attr: string

    Returns Promise<string>

  • _submit(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a submit button by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="submit"], button[type="submit"]

    example

    Assuming the following HTML-snippet:

    <form>
    <label>User: <input type="text" name="username" /></label>
    <label>Password: <input type="password" name="password" /></label>
    <button type="submit">Login</button>
    </form>

    Submitting the form with a [_click]{@link MouseActionApi._click}

    await _click(_submit('Login'));
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _summary(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a summary element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: summary

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_circle(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a circle element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: circle

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_ellipse(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a ellipse element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: ellipse

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_line(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a line element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: line

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_path(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a path element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: path

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_polygon(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a polygon element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: polygon

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_polyline(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a polyline element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: polyline

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_rect(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a rect element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: rect

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_text(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a text element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: text

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _svg_tspan(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a text-span element (from a svg-image) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: tspan

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _table(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a table element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: table

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _tableHeader(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a table-header element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: th

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _telephonebox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a tel field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="number"]

    example

    Assuming the following HTML-snippet:

       <input type="tel" name="tel-input" />
    

    Setting the value of this field:

       await _setValue(_telephonebox('tel-input'), '123456')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _textarea(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a textarea by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: textarea

    example

    Assuming the following HTML-snippet:

       <textarea name="textarea-input" ></textarea>
    

    Setting the value of this field:

       await _setValue(_textarea('textarea-input'), 'Some longer text maybe...')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _textbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a text input field (or a without any type attribute because this is considered as text input by the browsers) by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="text"], input:not([type])

    example

    Assuming the following HTML-snippet:

       <input type="text" name="first-name" />
    <input name="last-name" />

    Setting the value of this fields:

       await _setValue(_textbox('first-name') ,"Bill")
    await _setValue(_textbox('last-name') ,"Jobs")

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _time(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a time element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: time

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _timebox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a number field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="time"]

    example

    Assuming the following HTML-snippet:

       <input type="time" name="time-input" />
    

    Setting the value of this field:

       await _setValue(_timebox('time-input'), '19:09')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _title(): Promise<string>
  • Retrieves the current text content of the documents title element.

    example

    Assuming the following document:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Tested with Sakuli</title>
    </head>
    <body>
    </body>
    </html>

    Accessing the current Title of the element:

    const title = await _title() // -> "Tested with Sakuli";
    

    Returns Promise<string>

  • _type(query: SahiElementQueryOrWebElement, text: string): Promise<void>
  • _uncheck(query: SahiElementQueryOrWebElement): Promise<void>
  • _under(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located under the center of the anchor element on the y axis
    • The relational element is vertically aligned with the anchor element
    example
    +----+
    | 1 |
    +----+
    : +----+
    : | 2 |
    : +----+
    +----+
    | 3 |
    +----+

    In this case element 3 is "under" element 2 and element 3 is also "under" element 1, but element 2 is not "under" element 1 as they do not align vertically.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _underOrAbove(anchor: SahiElementQueryOrWebElement, offset?: number): SahiRelation
  • Creates a relation that identifies relational elements by the following criteria:

    • The center of the relational element is located under or above the center of the anchor element on the y axis
    • The relational element is vertically aligned with the anchor element
    example
    +----+
    | 3 |
    +----+
    : +----+
    : | 4 |
    : +----+
    +----+
    | 1 |
    +----+
    :
    +----+
    | 2 |
    +----+

    In this case element 2 and 3 are "under or above" element 1. Element 4 is not "under or above" element 1 as they do not align vertically.

    Parameters

    • anchor: SahiElementQueryOrWebElement
    • Optional offset: number

    Returns SahiRelation

  • _urlbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a url field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="url"]

    example

    Assuming the following HTML-snippet:

       <input type="url" name="url-input" />
    

    Setting the value of this field:

       await _setValue(_urlbox('url-input'), 'https://sakuli.io')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _video(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a video element by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: video

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _wait<P>(...__namedParameters: P): Promise<P extends WaitParameterWithExpression<R> ? R : 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. The truthy evaluated value of the expression will be returned from _wait.

    example

    // 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 and return the resulting boolean value
    const isVisible = await _wait(5000, () => _isVisible(_submit('Buy Now')));

    Type parameters

    • P: WaitParameter<any>

    Parameters

    • Rest ...__namedParameters: P

    Returns Promise<P extends WaitParameterWithExpression<R> ? R : void>

  • _weekbox(identifier: AccessorIdentifier, ...relations: SahiRelation[]): SahiElementQueryOrWebElement
  • Fetches a week field by an [identifier]{@link AccessorIdentifier} - restricted by the [relations]{@link RelationApi}

    Based on CSS selector: input[type="week"]

    If you want to set a value on this element please consider the supported formats

    example

    Assuming the following HTML-snippet:

       <input type="week" name="week-input" />
    

    Setting the value of this field:

       await _setValue(_weekbox('week-input'), '2019-W19')
    

    Parameters

    • identifier: AccessorIdentifier
    • Rest ...relations: SahiRelation[]

    Returns SahiElementQueryOrWebElement

  • _xy(): Promise<never>