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'),
34
+
output: z.string().describe('Raw output from the action')
35
+
});
36
+
26
37
// Extend base test to automatically track page
27
38
exportconsttest=base.extend({
28
-
page: async({ page },use)=>{
29
-
sessionManager.setPage(page);
30
-
awaituse(page);
31
-
},
39
+
page: async({ page },use)=>{
40
+
sessionManager.setPage(page);
41
+
awaituse(page);
42
+
}
32
43
});
33
44
34
45
// Initialize the LangChain agent with more detailed instructions
35
46
constinitializeAgent=()=>{
36
-
constmodel=createLLMModel();
47
+
constmodel=createLLMModel();
37
48
38
-
constprompt=`You are a web automation assistant. When given a natural language instruction:
49
+
constprompt=`You are a web automation assistant. When given a natural language instruction:
39
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
40
51
- For "get" or "get text" instructions, use the getText tool to retrieve content
41
52
- For "click" instructions, use the click tool to interact with elements
- For verification and assertions, use the assert tool
55
-
Return the operation result or content as requested.`;
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
+
}`;
56
74
57
-
constagent=createReactAgent({
58
-
llm: model,
59
-
tools: [
60
-
browser_click,
61
-
browser_type,
62
-
browser_get_text,
63
-
browser_navigate,
64
-
browser_snapshot,
65
-
browser_hover,
66
-
browser_drag,
67
-
browser_select_option,
68
-
browser_take_screenshot,
69
-
browser_go_back,
70
-
browser_wait,
71
-
browser_press_key,
72
-
browser_save_pdf,
73
-
browser_choose_file,
74
-
browser_assert,
75
-
browser_go_forward,
76
-
],
77
-
stateModifier: prompt,
78
-
});
75
+
constagent=createReactAgent({
76
+
llm: model,
77
+
tools: [
78
+
browser_click,
79
+
browser_type,
80
+
browser_get_text,
81
+
browser_navigate,
82
+
browser_snapshot,
83
+
browser_hover,
84
+
browser_drag,
85
+
browser_select_option,
86
+
browser_take_screenshot,
87
+
browser_go_back,
88
+
browser_wait,
89
+
browser_press_key,
90
+
browser_save_pdf,
91
+
browser_choose_file,
92
+
browser_assert,
93
+
browser_go_forward,
94
+
browser_page_assert
95
+
],
96
+
stateModifier: prompt,
97
+
responseFormat: {
98
+
prompt: `Return a stringified JSON object with exactly these fields:
0 commit comments