Short answer

For walkthrough scripts you plan to drift-check, use exact-match selectors: role=button[name="Invite teammate"] and text="Invite teammate". Avoid unquoted / substring text locators that keep matching after the label changes.

Why this is the durability rule

Drift detection only works if a real product change can fail the replay. Soft selectors that still match “Invite” after the UI says “Add member” will produce a green check and a lying video.

Preferred order (practical)

  1. data-testid when your app owns stable test ids
  2. Accessible role + exact name
  3. Quoted exact text
  4. Specific CSS / id
  5. XPath only as a last fallback — and plan to replace it

Agent Docu’s skill docs and prior-art recorder follow this rule on purpose. Details: /skill.

Authoring tip for your bot

When your Grok Bot explores the UI, ask it to emit selectors in that order and to refuse substring text= forms. Validate with:

python -m scripts author --steps-json steps.json --out flow.yaml …