# page.ai.analyzePageText()

## Ask a free-form question about the visible text on the current page and receive a natural-language answer.

Markdown

Asks a free-form question about the visible text on the current page and returns a natural-language answer. Useful for sanity checks, content audits, and verification tasks where you want a human-readable report rather than structured data.

## Signature

```ts
page.ai.analyzePageText(
  analysisToRun: string,
  options?: {
    additionalContext?: string;
    gptClient?: GptClient | LanguageModel;
  }
): Promise<string>
```

## Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `analysisToRun` | `string` | — | Plain-English description of the analysis to perform |
| `options.additionalContext` | `string` | — | Any context relevant to the analysis that is not present on the page itself (e.g. "This is a developer changelog page") |
| `options.gptClient` | `GptClient | LanguageModel` | Project default | Override the AI provider for this call |

## Returns

A `string` containing the AI's natural-language analysis. You can log it, attach it to the test report, or feed it into subsequent assertions.

## Usage

```ts
import { test } from 'donobu';

test('changelog contains no deprecated API warnings', async ({ page }) => {
  await page.goto('https://docs.example.com/changelog');

const report = await page.ai.analyzePageText(
    'List any mentions of deprecated APIs, breaking changes, or security warnings you find',
    { additionalContext: 'This is a developer-facing changelog for a REST API.' },
  );

console.log(report);

// Use the report as part of a structured assertion if needed
  expect(report.toLowerCase()).not.toContain('critical security');
});
```

## Practical use cases

- **Content verification**: confirm that key messaging or legal copy appears correctly
- **Deprecation audits**: scan changelogs or release notes for potentially impactful changes
- **Accessibility spot-checks**: ask whether the page contains any placeholder text or lorem ipsum that slipped into production
- **Localisation review**: verify that no untranslated strings are present on a localised page

## Notes

The analysis runs on the **raw extracted text** of the page, not the rendered HTML. Layout, visual hierarchy, and formatting are lost — results may be less accurate for pages where position and styling carry meaning. For structured extraction, prefer [`page.ai.extract`](/content/docs/playwright/api/page-ai-extract/index.html).
