Skip to main content

2024.03.04 | AskUI SDK Convenience Methods

· 2 min read
Johannes Dienst
Developer Advocate

Introduction

This week we improved on our docs. A guide for setting up your terminal and extensions in Visual Studio Code on Windows will improve your experience while developing AskUI Workflows.

We also fixed a display bug at the Supported Keys page.

In version 0.14.0 of the AskUI SDK we introduced some convenience methods to free users from writing repetitive code. This speeds up the development of AskUI Workflows and improves readability. Make sure to read the convenience docs which give you a detailed description on how to use each method.

Visual Studio Code Setup on Windows

Visual Studio Code is our recommended editor for developing AskUI workflows. Our docs for the AskUI Development Environment now have a section that helps you to setup Visual Studio Code for developing AskUI workflows efficiently:

  • Terminal configuration
  • Recommended extensions for Jest Runner, ESLint & Live View

Convenience Methods

We introduced the following methods:


clickButton(label: string)

Searches for an element of type button with a label and clicks it when found.

await aui.clickButton('Sign Up');

clickIcon(description: string)

Clicks an icon based on a description.

await aui.clickIcon('Logo looking like an apple');

clickText(text: string)

Searches for a text element and clicks it when found.

await aui.clickText('A big bear');

clickTexts(texts: string[])

Searches for text elements and clicks them one after another when found.

await aui.clickTexts(['A big bear', 'Brown Fox', 'Walks into a bar']);

clickTextfield(placeholder: string)

Searches for an element of type textfield with a specific placeholder text. If found, clicks it.

await aui.clickTextfield('E-Mail Address');

dragTo(element1: Executable, element2: Executable)

warning

This method is not working as intended and will be removed with the next release!

Drags element1 to element2.

Both must be a moveMouse() or moveMouseTo() instruction as in the example below.

await aui.dragTo(
aui.moveMouseTo().text('AskUI'),
aui.moveMouseTo().text('UI Automation')
);

pressKeyNTimes(key: PC_AND_MODIFIER_KEY, times = 2)

Press a key multiple times. At least two times.

await aui.pressKeyNTimes('right');
await aui.pressKeyNTimes('left', 3);

pressKeys(keys: PC_AND_MODIFIER_KEY[])

Press an array of keys one after another.

await aui.pressKeys(['right', 'left', 'enter']);

waitUntil(AskUICommand: Executable, maxTry = 5, waitTime = 2000)

Wait until an AskUICommand does not fail.

Use it to wait for an element to appear like this:

await aui.waitUntil(aui.expect().text('GitHub').exists());