agentleFS
crosstech-solutions-bvcrosstech-solutions-bv/swing-mcp/skills/swing-ui-testing/SKILL.md

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.

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
  1. Very specific:

    Deterministic synchronisation: Never rely on sleeps. Use wait_for with an explicit condition (COMPONENT_TEXT, COMPONENT_VISIBLE, …

    line 8
  2. Very specific:

    Assert via the model, not pixels: Prefer get_component_details, get_table_data, and get_list_items for assertions — they read the actual …

    line 12
  3. Distinctive:

    Run the scenario steps.

    line 20
  4. Very specific:

    Verify: wait_for a success condition, then check resulting state with get_component_details (e.g.

    line 29
  5. Very specific:

    Row actions: after selecting, use click with clickType: "DOUBLE" to open, or select_context_menu_item for the row's context menu.

    line 35
  6. Very specific:

    Test accelerators and shortcuts with key chords, e.g.

    line 50
  7. Very specific:

    Use set_clipboard + press_key with CTRL+V to test paste handling, and get_clipboard to assert what the app copied after CTRL+C.

    line 56
  8. Very specific:

    Use window tools (resize_window, maximize_window, close_window, …) to test layout and shutdown behavior.

    line 62
  9. Very specific:

    Interaction has no effect: check get_component_details — the component may be disabled or not visible.

    line 72

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. launch_app with the application's full java command (use attach_to_app only when the app must keep running after the test).
  2. wait_for with WINDOW_TITLE (or WINDOW_COUNT) to ensure the main window is up before interacting.
  3. Run the scenario steps.
  4. stop_app to end the session, even on failure, so the launched JVM is cleaned up.

2. Form filling and validation

  1. take_snapshot (optionally filter: "ENABLED_ONLY") to find input fields and buttons.
  2. fill each text field, spinner, or editable combo box (JTextField/JSpinner/JComboBox in Swing, TextInputControl/Spinner/ComboBox in JavaFX); use type_text when the form relies on key listeners or per-keystroke validation.
  3. select_option for combo boxes and click for checkboxes/radio buttons.
  4. Submit with click on the confirm button, or press_key with ENTER.
  5. Verify: wait_for a success condition, then check resulting state with get_component_details (e.g. an error label's text, or a button becoming enabled/disabled).

3. Tables, lists, and trees

  • Verify data: get_table_data with startRow/endRow to assert column names and cell values (JTable in Swing, TableView in JavaFX); get_list_items for JList items or visible JTree rows (ListView/TreeView in JavaFX).
  • Select: select_table_cell (row/col), select_option (index or visible text), select_tree_node with a Root > Folder > Leaf path.
  • Row actions: after selecting, use click with clickType: "DOUBLE" to open, or select_context_menu_item for the row's context menu.
  • Long content: scroll inside the JScrollPane (or ScrollPane in 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 and modifiers such as CTRL. Check the result with a screenshot or the app's own status text.

4. Menus and dialogs

  1. select_menu_item with a path like File > Save to trigger menu actions.
  2. list_dialogs to detect and inspect the resulting dialog (type, title, message, buttons).
  3. handle_dialog to click a button by text (e.g. OK, Cancel) or to pick a file in a JFileChooser via filePath.
  4. wait_for with WINDOW_COUNT or COMPONENT_GONE to confirm the dialog closed.

5. Keyboard navigation and focus

  1. focus a starting component, then press_key with TAB / SHIFT+TAB to walk the focus traversal order.
  2. take_snapshot (or get_component_details) to verify which component holds focus after each step.
  3. Test accelerators and shortcuts with key chords, e.g. press_key with CTRL+S.
  4. For modal dialogs, verify focus moves into the dialog and stays there until it is closed.

6. Drag and drop, and clipboard

  • drag from 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) needs robot: true and the window in front; drags inside one component (sliders, chart zoom) work without it.
  • Use set_clipboard + press_key with CTRL+V to test paste handling, and get_clipboard to assert what the app copied after CTRL+C.

7. Multi-window scenarios

  1. list_windows after actions that may open new frames.
  2. select_window by index to switch the active window before snapshotting or interacting.
  3. Use window tools (resize_window, maximize_window, close_window, …) to test layout and shutdown behavior.

8. Visual verification

  • take_screenshot of the whole window at key checkpoints, or of a single component via uid for focused comparisons.
  • Screenshots are saved under the server's screenshot-dir and 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_for with COMPONENT_ENABLED before retrying.
  • Test hangs on a step: a modal dialog is probably blocking the window — call list_dialogs and handle it.
  • For connection/session failures, use the troubleshooting skill.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.