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)
data-testidwhen your app owns stable test ids- Accessible role + exact name
- Quoted exact text
- Specific CSS / id
- 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 …