swing-ui-testing
Skill4 starsChanged 17 days agoMITView on GitHub
Uses Swing MCP to test and verify Java desktop application behavior, in Swing or JavaFX. Use when writing or executing UI test scenarios against Swing or JavaFX apps - filling forms, verifying tables and trees, exercising menus and dialogs, testing keyboard navigation, and visually verifying results.
In this repository2 other files it gives its agents.
- swing-mcpSkill
- troubleshootingSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 1 is distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Deterministic synchronisation: Never rely on sleeps. Use wait_for with an explicit condition (COMPONENT_TEXT, COMPONENT_VISIBLE, …
- Very specific: line 12
Assert via the model, not pixels: Prefer get_component_details, get_table_data, and get_list_items for assertions — they read the actual …
- Distinctive: line 20
Run the scenario steps.
- Very specific: line 29
Verify: wait_for a success condition, then check resulting state with get_component_details (e.g.
- Very specific: line 35
Row actions: after selecting, use click with clickType: "DOUBLE" to open, or select_context_menu_item for the row's context menu.
- Very specific: line 50
Test accelerators and shortcuts with key chords, e.g.
- Very specific: line 56
Use set_clipboard + press_key with CTRL+V to test paste handling, and get_clipboard to assert what the app copied after CTRL+C.
- Very specific: line 62
Use window tools (resize_window, maximize_window, close_window, …) to test layout and shutdown behavior.
- Very specific: line 72
Interaction has no effect: check get_component_details — the component may be disabled or not visible.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Core Concepts
Deterministic synchronisation: Never rely on sleeps. Use wait_for with an explicit condition (COMPONENT_TEXT, COMPONENT_VISIBLE, COMPONENT_ENABLED, COMPONENT_EXISTS, COMPONENT_GONE, WINDOW_TITLE, WINDOW_COUNT, EDT_IDLE) and a timeoutMs to make test steps deterministic.
Fresh snapshots: Component UIDs come from take_snapshot and can go stale after any action that changes the UI. Re-snapshot before asserting on state, and whenever an interaction fails to find a component.
Assert via the model, not pixels: Prefer get_component_details, get_table_data, and get_list_items for assertions — they read the actual component model state. Use take_screenshot only for visual verification.
Workflow Patterns
1. Test session setup and teardown
launch_appwith the application's full java command (useattach_to_apponly when the app must keep running after the test).wait_forwithWINDOW_TITLE(orWINDOW_COUNT) to ensure the main window is up before interacting.- Run the scenario steps.
stop_appto end the session, even on failure, so the launched JVM is cleaned up.
2. Form filling and validation
take_snapshot(optionallyfilter: "ENABLED_ONLY") to find input fields and buttons.filleach text field, spinner, or editable combo box (JTextField/JSpinner/JComboBoxin Swing,TextInputControl/Spinner/ComboBoxin JavaFX); usetype_textwhen the form relies on key listeners or per-keystroke validation.select_optionfor combo boxes andclickfor checkboxes/radio buttons.- Submit with
clickon the confirm button, orpress_keywithENTER. - Verify:
wait_fora success condition, then check resulting state withget_component_details(e.g. an error label's text, or a button becoming enabled/disabled).
3. Tables, lists, and trees
- Verify data:
get_table_datawithstartRow/endRowto assert column names and cell values (JTablein Swing,TableViewin JavaFX);get_list_itemsforJListitems or visibleJTreerows (ListView/TreeViewin JavaFX). - Select:
select_table_cell(row/col),select_option(index or visible text),select_tree_nodewith aRoot > Folder > Leafpath. - Row actions: after selecting, use
clickwithclickType: "DOUBLE"to open, orselect_context_menu_itemfor the row's context menu. - Long content:
scrollinside theJScrollPane(orScrollPanein JavaFX) to reach off-screen rows before interacting via mouse emulation. Components without a scroll pane get mouse-wheel notches instead. - Zoom and pan: graph, chart and map canvases that react to the wheel themselves take
mouse_wheel, with a point andmodifierssuch asCTRL. Check the result with a screenshot or the app's own status text.
4. Menus and dialogs
select_menu_itemwith a path likeFile > Saveto trigger menu actions.list_dialogsto detect and inspect the resulting dialog (type, title, message, buttons).handle_dialogto click a button by text (e.g.OK,Cancel) or to pick a file in aJFileChooserviafilePath.wait_forwithWINDOW_COUNTorCOMPONENT_GONEto confirm the dialog closed.
5. Keyboard navigation and focus
focusa starting component, thenpress_keywithTAB/SHIFT+TABto walk the focus traversal order.take_snapshot(orget_component_details) to verify which component holds focus after each step.- Test accelerators and shortcuts with key chords, e.g.
press_keywithCTRL+S. - For modal dialogs, verify focus moves into the dialog and stays there until it is closed.
6. Drag and drop, and clipboard
dragfrom a source UID to a target UID to test drag-and-drop behavior (Swing only), then verify the result via snapshots or model data. Native drag-and-drop between components (lists, trees,TransferHandler) needsrobot: trueand the window in front; drags inside one component (sliders, chart zoom) work without it.- Use
set_clipboard+press_keywithCTRL+Vto test paste handling, andget_clipboardto assert what the app copied afterCTRL+C.
7. Multi-window scenarios
list_windowsafter actions that may open new frames.select_windowby index to switch the active window before snapshotting or interacting.- Use window tools (
resize_window,maximize_window,close_window, …) to test layout and shutdown behavior.
8. Visual verification
take_screenshotof the whole window at key checkpoints, or of a single component viauidfor focused comparisons.- Screenshots are saved under the server's
screenshot-dirand the path is returned; reference the file rather than inlining the image unless needed.
Troubleshooting
- Component not found / stale UID: take a fresh
take_snapshot; the UI likely changed. - Interaction has no effect: check
get_component_details— the component may be disabled or not visible;wait_forwithCOMPONENT_ENABLEDbefore retrying. - Test hangs on a step: a modal dialog is probably blocking the window — call
list_dialogsand handle it. - For connection/session failures, use the troubleshooting skill.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

