Runbook 16.5 — Action Method Synthesis

Convert validated locators into typed elements, primitive action methods, composite actions, and page-object-ready outputs without jumping straight to unsafe full-test generation.

Objective

Key shift

The system does not guess full tests from labels. It derives typed elements, synthesizes bounded actions, and composes workflows only when confidence is strong enough.

Definition of done

System overview

Flow
LOCATOR MAP → ELEMENT TYPING → ACTION METHODS → COMPOSITES → PAGE OBJECTS → TEST SKELETONS
Locator map Validated selectors and interactive element inventory from Sprint 16.
Element typing Normalize role, HTML type, labels, placeholders, and semantic intent.
Action methods Generate bounded primitive methods such as fillUsername and submitLogin.
Composite actions Build higher-level workflows like loginAs when evidence is strong.
Page objects Translate artifacts into maintainable action-oriented class methods.
Test skeletons Use composites later as the safe input layer for generated test structure.

Element typing rules

textbox + email/username label      -> auth.username
textbox + password type/label      -> auth.password
button + sign in / login / submit  -> auth.submit
textbox + search/query             -> search.query
button + save                      -> entity.save
button + publish                   -> entity.publish
button + delete                    -> entity.delete
Rule

Naming conventions matter, but naming alone is not enough. Intent inference should use weighted evidence: role, HTML type, label, placeholder, nearby controls, and surrounding component context.

Confidence model

0.90 and above Safe candidate. Can be used for primitive methods and high-confidence composition.
0.75 to 0.89 Review recommended. Keep primitive output, limit composition.
Below 0.75 Do not compose. Preserve as low-confidence candidate or generic interaction.
Human override

Composite generation is a convenience, not a license to hallucinate behavior. If confidence is weak, keep the output primitive and reviewable.

Artifact contract

Canonical location test-results/locator-intelligence/
Typed elements element-type-map.json
Primitive methods action-method-candidates.json
Composite methods composite-action-candidates.json
Recommended structure
test-results/
  locator-intelligence/
    locator-map.json
    element-type-map.json
    action-method-candidates.json
    composite-action-candidates.json
Critical

These artifacts let the system evolve from locator intelligence into safe action synthesis without skipping validation or collapsing into opaque generation.

Commands

Typing, methods, composites

# Element typing
node agents/element-typing/run.js test-results/locator-intelligence/sample-locator-map.json

# Primitive action synthesis
node agents/action-method-synthesis/run.js test-results/locator-intelligence/element-type-map.json

# Composite action synthesis
node agents/composite-action-synthesis/run.js test-results/locator-intelligence/action-method-candidates.json
Operator rule

Generate primitive methods freely from validated inputs. Generate composite actions only when the surrounding component and intent evidence are strong enough to justify them.

Expected outputs

Failure modes

Generated code target

export class LoginPage {
  constructor(page) {
    this.page = page;
    this.usernameField = page.getByLabel('Email');
    this.passwordField = page.getByLabel('Password');
    this.signInButton = page.getByRole('button', { name: 'Sign in' });
  }

  async fillUsername(value) {
    await this.usernameField.fill(value);
  }

  async fillPassword(value) {
    await this.passwordField.fill(value);
  }

  async submitLogin() {
    await this.signInButton.click();
  }

  async loginAs(username, password) {
    await this.fillUsername(username);
    await this.fillPassword(password);
    await this.submitLogin();
  }
}
Why this matters

The real value is not raw code generation. The value is turning validated system understanding into reusable methods that reduce boilerplate and improve consistency.

Connection to the intelligence layer

Outcome

The system moves from “knowing what elements exist” to “knowing how to interact with them predictably.”

Operational value