Use when Playwright locators can’t express the query:
{ "interaction_action": { "click_element": { "xpath": "//table[@id='results']//tr[contains(@class, 'active')]/td[3]/button", "prompt_instructions": "Click the action button in the active row" } }}
XPath locators are more fragile than Playwright commands. Prefer command when possible.
Prompt Instructions
Natural language description used when locators fail:
{ "click_element": { "command": "get_by_role(\"button\", name=\"Continue\")", "prompt_instructions": "Click the green Continue button at the bottom of the checkout form" }}
Writing Good Instructions
Good:
{"prompt_instructions": "Click the blue 'Add to Cart' button below the product price"}{"prompt_instructions": "Click Submit next to the Cancel button at the form bottom"}{"prompt_instructions": "Click on order number {order_id[0]} in the orders table"}
Poor:
{"prompt_instructions": "Click the button"}{"prompt_instructions": "Click it"}
Include visual details, position, and context in prompt instructions.
Locator Selection Strategy
1. Element has role + accessible name? → get_by_role()2. Form element with label? → get_by_label()3. Has data-testid? → get_by_test_id()4. Unique visible text? → get_by_text()5. Unique ID or class? → locator() with CSS6. Complex DOM traversal? → xpath7. Dynamic or variable? → prompt_instructions primarily