@litocodes/persona-test 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +13 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -144,22 +144,31 @@ async function runAgent(url, persona, options = {}) {
144
144
  const actionHistory = [];
145
145
  const failedIds = [];
146
146
  let outcome = 'MAX_ACTIONS';
147
+ let actionCount = 0;
147
148
 
148
149
  for (let step = 1; step <= persona.maxActions; step++) {
149
150
  const html = await page.content();
150
151
  const { domMap, elements, elementCount } = parsePage(html, failedIds);
151
152
 
152
- if (elementCount === 0) { await page.mouse.wheel(0, 300); continue; }
153
+ if (elementCount === 0) {
154
+ console.log(` ⚠️ [${persona.name}] No elements found, scrolling...`);
155
+ await page.mouse.wheel(0, 300);
156
+ continue;
157
+ }
153
158
 
154
159
  const decision = await getAgentAction(domMap, persona, actionHistory);
160
+ actionCount++;
155
161
 
156
- console.log(` 🤖 [${persona.name}] Step ${step}: ${decision.action} [${decision.elementId}] - ${decision.reason?.substring(0, 40)}`);
162
+ console.log(` 🤖 [${persona.name}] Step ${actionCount}: ${decision.action} [${decision.elementId}] - ${decision.reason?.substring(0, 40)}`);
157
163
 
158
164
  if (decision.action === 'done') { outcome = 'SUCCESS'; break; }
159
165
  if (decision.action === 'quit') { outcome = 'ABANDONED'; break; }
160
166
 
161
167
  const target = decision.elementId ? findElementById(elements, decision.elementId) : null;
162
- if (!target) continue;
168
+ if (!target) {
169
+ console.log(` ⚠️ [${persona.name}] Invalid element ID, skipping...`);
170
+ continue;
171
+ }
163
172
 
164
173
  try {
165
174
  const locator = page.locator(target.selector).first();
@@ -176,6 +185,7 @@ async function runAgent(url, persona, options = {}) {
176
185
  if (actionHistory.length > 3) actionHistory.shift();
177
186
 
178
187
  } catch (e) {
188
+ console.log(` ⚠️ [${persona.name}] Action failed: ${e.message.split('\n')[0].substring(0, 40)}`);
179
189
  failedIds.push(decision.elementId);
180
190
  }
181
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litocodes/persona-test",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "AI User Testing with Personality - Simulate real users breaking your website",
5
5
  "main": "index.js",
6
6
  "type": "module",