You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.describe('The type of action performed (assert, click, type, etc)'),
33
-
error: z.string().describe('Error message if any, empty string if none'),
33
+
exception: z.string().describe('Error message if any, empty string if none'),
34
34
output: z.string().describe('Raw output from the action')
35
35
});
36
36
@@ -46,59 +46,262 @@ export const test = base.extend({
46
46
constinitializeAgent=()=>{
47
47
constmodel=createLLMModel();
48
48
49
-
constprompt=`You are a web automation assistant. When given a natural language instruction:
50
-
- Always call the snapshot tool first to analyze the page structure and elements, so you can understand the context ad the elements available on the page to perform the requested action
51
-
- For "get" or "get text" instructions, use the getText tool to retrieve content
52
-
- For "click" instructions, use the click tool to interact with elements
53
-
- For "type" instructions, use the type tool with the text and target
54
-
- For navigation, use the goto tool with the provided URL
55
-
- For understanding page structure and elements, use the aria_snapshot tool
56
-
- For hover interactions, use the hover tool over elements
57
-
- For drag and drop operations, use the drag tool between elements
58
-
- For selecting options in dropdowns, use the selectOption tool
59
-
- For taking screenshots, use the takeScreenshot tool
60
-
- For going back in history, use the goBack tool
61
-
- For waiting for elements, use the wait tool
62
-
- For pressing keys, use the pressKey tool
63
-
- For saving PDFs, use the savePDF tool
64
-
- For choosing files, use the chooseFile tool
65
-
- While calling the verification and assertion tools, DO NOT assume or make up any expected values. Use the values as provided in the instruction only.
66
-
- For verification and assertions like {"isVisible", "hasText", "isEnabled", "isChecked"}, use the browser_assert tool
67
-
- For page assertions like {page title, current page url} use the browser_page_assert tools
68
-
Return a stringified JSON object with exactly these fields:
69
-
{
70
-
"action": "<type of action performed>",
71
-
"error": "<error message or empty string>",
72
-
"output": "<your output message>"
73
-
}`;
49
+
constprompt=`You are a Playwright Test Automation Expert specializing in browser automation and testing. Your primary goal is to execute user instructions accurately and sequentially while maintaining robust error handling and verification.
50
+
51
+
MANDATORY REQUIREMENTS:
52
+
53
+
1. Tool Usage Rules:
54
+
- MUST use appropriate tool for EVERY action
55
+
- NEVER return direct responses without tool use
56
+
- NO claiming action completion without tool result
57
+
- INVALID to skip required tools like snapshot
58
+
59
+
2. Response Format Rules:
60
+
- ALL responses must have tool result
61
+
- NO empty/direct text responses
62
+
- Format must match schema exactly
63
+
- Must include actual tool output
64
+
65
+
3. Tool Result Requirements:
66
+
- Must wait for and include tool output
67
+
- Cannot fabricate/assume tool results
68
+
- Must reflect actual tool execution
69
+
- Must be parseable JSON format
70
+
71
+
4. Error vs Tool Skip:
72
+
- Missing tool use = INVALID response
73
+
- Tool error = Valid with exception
74
+
- NEVER skip tool to avoid errors
75
+
- Report ALL tool execution results
76
+
77
+
5. Response Examples:
78
+
79
+
INVALID (No Tool Use):
80
+
{
81
+
"action": "type",
82
+
"exception": "",
83
+
"output": "Typed password in the textbox" // NO TOOL RESULT!
0 commit comments