import('gui-test') provides automated GUI testing via synthetic input injection (mouse, keyboard, touch) using Win32 SendInput, enabling regression testing without manual interaction.
gt := import('gui-test')
// Create a test suite
suite := gt.testSuite('Button Tests')
gt.testCase(suite, 'click save button', fn(result) {
hwnd := gt.testFindWindow(?, 'My App')
gt.testAssert(result, hwnd != ?, 'window found')
rect := gt.testGetWindowRect(hwnd)
gt.testMouseClick(rect.x + 50, rect.y + 100)
title := gt.testGetWindowText(hwnd)
gt.testAssertEqual(result, title, 'Saved', 'title updated')
})
gt.testRun(suite)
println(gt.testReport(suite))
| Function | Description |
|---|---|
testMouseMove(x, y) |
Move cursor to absolute screen position |
testMouseClick(x, y) |
Left click at (x, y) |
testMouseRightClick(x, y) |
Right click at (x, y) |
testMouseDoubleClick(x, y) |
Double left click at (x, y) |
testMouseDrag(x1, y1, x2, y2) |
Drag from (x1,y1) to (x2,y2) |
testMouseWheel(delta) |
Scroll wheel (delta > 0 scrolls up) |
| Function | Description |
|---|---|
testKeyDown(vk) |
Press a key down |
testKeyUp(vk) |
Release a key |
testKeyPress(vk) |
Press and release a key |
testTypeText(text) |
Type a string character by character (Unicode) |
testKeyCombo(keys) |
Press a key combination (e.g. [VK_CONTROL, 67] for Ctrl+C) |
Creates a named test suite for organizing test cases.
Adds a test case to the suite. The callback receives a result object for assertions.
Runs all tests in the suite. Returns results.
Asserts that condition is true.
Asserts that actual equals expected.
Generates a text report of test results.
Returns {x, y, w, h} for a window.
Returns the window title text.
Returns true if a window is visible.
Returns the currently focused window handle.
Finds a window by class name or title.
Captures a bitmap of a window for visual regression testing.
Frees a captured screenshot.
| Constant | Value |
|---|---|
INPUT_MOUSE |
0 |
INPUT_KEYBOARD |
1 |
| Constant | Value |
|---|---|
MOUSEEVENTF_MOVE |
1 |
MOUSEEVENTF_LEFTDOWN |
2 |
MOUSEEVENTF_LEFTUP |
4 |
MOUSEEVENTF_RIGHTDOWN |
8 |
MOUSEEVENTF_RIGHTUP |
16 |
MOUSEEVENTF_WHEEL |
2048 |
MOUSEEVENTF_ABSOLUTE |
32768 |
| Constant | Value |
|---|---|
KEYEVENTF_KEYDOWN |
0 |
KEYEVENTF_KEYUP |
2 |
KEYEVENTF_UNICODE |
4 |