DEV Community

Simon Pfeiffer
Simon Pfeiffer

Posted on • Originally published at codesphere.ghost.io on

The Future of UI Testing? - AI automated testing with AskUI

The Future of UI Testing? - AI automated testing with AskUI

UI testing can be an incredibly difficult task. Your tests need to be able to adapt to slight changes in sizes and devices in a way that usually requires an incredibly in depth integration with your web app.

Ideally, you could have the cognitive flexibility of a human to test your interfaces, but that kind of manual solution is simply not feasible at scale.

So how can you conduct UI testing with the intelligence of a human but without the massive investment of automated testing? That’s where AskUI comes in


What is Ask UI

AskUI is an automated UI testing tool that doesn’t go under the hood of your web app. Instead it sits in the same position as a user and uses artificial intelligence to identify and test out different UI elements.

Tests for AskUI can be written with an incredibly readable, but also highly-customizable, API.

AskUI is currently in early access, but you can get setup with their demo in just a couple minutes.


Setting up the Demo

If you want to get a sense of how AskUI works, we can set up an empty project with:

npm init -y

Install AskUI:

npm i -D askui

While AskUI provides the API for controlling your operating system to interact and scan the UI, it doesn’t provide a way to organize, write, and execute tests. However, it integrates well with libraries like Jest:

npm i -D jest

And then let’s use Typescript in this example:

npm i -D @types/jest ts-jest ts-node typescript

We can then setup the demo AskUI test suite with:

npx askui init

The default test in this demo will find some text and move the cursor to the text to click on it:

<!--kg-card-begin: html--><!--kg-card-end: html-->

Of course, you can customize this to target specific text, buttons, forms, as well as interact with the page in all kinds of ways.

Before we can run this, make sure you give your IDE permission to control your cursor and record your screen.

To run this test:

npx jest test/my-first-askui-test-suite.test.ts --config ./test/jest.config.ts

If everything is setup correctly, you should see your mouse move over to a piece of text and click on it:

The Future of UI Testing? - AI automated testing with AskUI


Stay Tuned

Again, AskUI is in early access so this is only the start of what AI powered front-end testing is capable of.

Nevertheless, the ease at which you can set up UI tests with AskUI is incredibly exciting! Tools like this allow robust testing to be a feasible process for startups who don’t have the resources for full on QA teams.

Top comments (0)