Skip to content

Commit f18c2ce

Browse files
committed
drop the dom snapshot to save tokens
1 parent f78eabd commit f18c2ce

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

index.js

+7-28
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ instructions:
4646
2. After the mapping and description phase, you'll be provided a spec that
4747
you wrote to focus on specifically, one at a time. You'll begin a loop
4848
executing actions in order to fulfill the spec. On each turn, you'll be
49-
provided a screenshot, a DOM snapshot in JSON format, and the current
49+
provided a screenshot, a HTML dump, and the current
5050
mouse cursor position and other metadata.
5151
5252
- Your goal is to interact only with the elements necessary to fulfill
@@ -69,11 +69,12 @@ instructions:
6969
- You always adjust your mouse position to the correct location before
7070
clicking or proceeding with interactions if it seems like your mouse
7171
position is off.
72-
- You are always provided with a screenshot AND chrome developer tools
73-
protocol-generated DOM snapshot in JSON format, which includes offset
74-
rectangles to allow you to locate elements on the page.
75-
- You always make up appropriate cssSelectors based on the DOM
76-
snapshot, by relating the DOM snapshot to the screenshot you are
72+
- You are always provided with a screenshot AND a copy of the current
73+
rendered HTML of the page. You can use the HTML to cross-reference
74+
with the screenshot to make sure you are interacting with the correct
75+
elements.
76+
- You always make up appropriate cssSelectors based on the HTML
77+
snapshot, by relating the HTML snapshot to the screenshot you are
7778
provided, and then coming up with a valid css selector that you can
7879
use to interact with the element in question. You always use the nth
7980
property to disambiguate between multiple elements that match the same
@@ -400,17 +401,6 @@ async function runTestSpec({ page, runId, spec, client, maxIterations = 10 }) {
400401
url: screenshotImageUrl,
401402
},
402403
},
403-
{
404-
type: "text",
405-
text: `
406-
Here is the DOM snapshot in JSON format:
407-
\`\`\`
408-
${fs.readFileSync(
409-
`./trajectories/${runId}/screenshot-${k}.json`,
410-
)}
411-
\`\`\`
412-
`,
413-
},
414404
{
415405
type: "text",
416406
text: `
@@ -570,17 +560,6 @@ async function executeAction({
570560
}
571561

572562
async function saveScreenshotWithCursor({ page, path, client }) {
573-
// Capture DOM snapshot
574-
const domSnapshot = await client.send("DOMSnapshot.captureSnapshot", {
575-
computedStyles: [],
576-
includeDOMRects: true,
577-
includePaintOrder: true,
578-
});
579-
580-
// Save DOM snapshot to file
581-
const snapshotPath = path.replace(".png", ".json");
582-
fs.writeFileSync(snapshotPath, JSON.stringify(domSnapshot, null, 2));
583-
584563
// Capture the HTML snapshot
585564
const html = await page.content();
586565
fs.writeFileSync(path.replace(".png", ".html"), html);

0 commit comments

Comments
 (0)