From 4a5bf3c3a38b87985d857cfa7e7899aa344d7f01 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Wed, 31 Dec 2025 10:38:55 +0100 Subject: [PATCH] Update prompt.md --- playwriter/src/prompt.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/playwriter/src/prompt.md b/playwriter/src/prompt.md index 50a3954..fbfc746 100644 --- a/playwriter/src/prompt.md +++ b/playwriter/src/prompt.md @@ -177,7 +177,7 @@ console.log(snapshot) ## getting outputs of code execution -You can use `console.log` to print values you want to see in the tool call result. For seeing logs across runs you can store then in `state.logs` and then print them later, filtering and paginating them too. +You can use `console.log` to print values you want to see in the tool call result. For seeing logs across runs you can store strings in `state.logs` and then print them later, filtering and paginating them too. ## using page.evaluate @@ -199,22 +199,6 @@ const pageInfo = await page.evaluate(() => ({ console.log(pageInfo) ``` -## read logs during interactions - -you can see logs during interactions with `page.on('console', msg => console.log(`Browser log: [${msg.type()}] ${msg.text()}`))` - -then remember to call `context.removeAllListeners()` or `page.removeAllListeners('console')` to not see logs in next execute calls. - -## reading past logs - -you can keep track of logs using `state.logs = []; page.on('console', msg => state.logs.push({ type: msg.type(), text: msg.text() }))` - -later, you can read logs that you care about. For example, to get the last 100 logs that contain the word "error": - -`console.log('errors:'); state.logs.filter(log => log.type === 'error').slice(-100).forEach(x => console.log(x))` - -then to reset logs: `state.logs = []` and to stop listening: `page.removeAllListeners('console')` - ## using getLatestLogs to read browser console logs The system automatically captures and stores up to 5000 browser console logs per page. Logs are automatically cleared when a page reloads or navigates to a new URL. You can retrieve logs using the `getLatestLogs` function: