# Page Assertions

## page.assertTitle

Asserts that the page title satisfies the given constraint

![page.assertTitle](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCFtNdmvUDiYHFk0K_%2Fpage.assertTitle2.png?alt=media\&token=1c438d0c-e4d5-4abb-ab24-9bc20d03fe05)

## page.assertUrl

Asserts that the page URL satisfies the given constraint

![page.assertUrl](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCG4D2Kkh4HXQg3cB3%2Fpage.assertUrl.png?alt=media\&token=32e48d14-f797-45cf-a2ce-83f056106f65)

## page.assertContent

Asserts that the page content (HTML) satisfies the given constraint

![page.assertContent](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGJVPz09_bWaxV_0w%2Fpage.assertHtml.png?alt=media\&token=5576025a-d4be-4cd7-84da-fc657c07d115)

## page.assertNodeCount

Asserts that number of elements matching a specified selector satisfies the given constraint

![page.assertNodeCount](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGPvcuiOAwZA-KGaA%2Fpage.assertNodeCount.png?alt=media\&token=f86af550-0ee1-43ba-8bba-776100d6c180)

## page.assertScroll

Asserts that [window scroll](https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll) offset satisfies the given constraint

![page.assertScroll](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGWA_6Tx69qhsPqSJ%2Fpage.assertScroll.png?alt=media\&token=307fded3-5214-4241-b3dc-59c1383a6a94)

## page.assertVar

Asserts that variable associated with a given name satisfies the given constraint

![page.assertVar](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGbs_2K67E-98Xg2p%2Fpage.assertVar.png?alt=media\&token=df663d0f-d131-4a92-a15b-ec3c754ffbc7)

## page.assertScreenshot

Asserts that screenshot of the page matches already approved one

![page.assertScreenshot](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGt6z3UxgnFatvuLB%2Fpage.assertScreenshot.png?alt=media\&token=b028f53e-fb8b-46ba-8b3b-b0a6be6e6583)

![page.assertScreenshot advanced options](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCGvrK-P5zqr83LyOj%2Fpage.assertScreenshot2.png?alt=media\&token=6aa99e02-08dd-4b89-b54a-6bf9eedab2e6)

## page.assertRest

Makes HTTP/S request and asserts that the response satisfies the given constraint.

{% hint style="info" %}
The method automatically assigns the response text data to template variable `PUPPETRY_LAST_RESPONSE_TEXT`
{% endhint %}

![ page.assertRest](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LvtyPvPEEJOsAH6v9kO%2F-LvtymRgPCHMhNKYpowt%2Fassert-rest-post.png?alt=media\&token=593e8904-66f8-4d3d-bf61-a5a579d8e822)

## page.assertResponse

Asserts that the HTTP/S response satisfies the given constraint

![page.assertResponse](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LvtyPvPEEJOsAH6v9kO%2F-LvtyxdlScBTGR6_N61I%2Fassert-response.png?alt=media\&token=37ef58a6-58de-4e69-aa09-f95d10337329)

## page.assertConsoleMessage

Asserts there were (no) console messages sent to console to satisfy the given constraint

![page.assertConsoleMessage](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCJn0lBCWku-S0XY-_%2F-LuCU7aLM7uB1v8mc--f%2Fpage.assertConsoleMessage.png?alt=media\&token=28e030cf-16e6-4f17-bdab-e02fa4d0f69d)

## page.assertDialog

Asserts there was called a dialog (alert, beforeunload, confirm or prompt).

![page.assertDialog](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCJn0lBCWku-S0XY-_%2F-LuCUBG7j6IBYHuLlS2n%2Fpage.assertDialog.png?alt=media\&token=73bf4d8e-027b-4b01-8170-0385f8e37a72)

## page.assertPerformanceAssetWeight

Asserts that total weight of assets (JavaScript, CSS, images, media, fonts, XHR) on the page satisfies the given budget.&#x20;

This assertion makes Puppetry to intercept HTTP requests. It compares the given limits to the encoded length of the requests. Note that the request length is considered `0` when request loaded from cache. So it makes sense to place this step next to the very first `page.goto` in the test suite.

![page.assertPerformanceAssetWeight](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCHsENqomQr7BK4e0N%2Fpage.assertPerformanceWeight.png?alt=media\&token=89e6e1e2-fa92-4d8d-ba85-4dccc12a3897)

## page.assertPerformanceAssetCount

Asserts that total number of requested assets (JavaScript, CSS, images, media, fonts, XHR) on the page satisfies the given budget.

![page.assertPerformanceAssetCount](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCI9wLypFFWlj1OgZC%2Fpage.assertPerformanceCount.png?alt=media\&token=430f3a64-967e-487d-b066-09ca314c3a4f)

## page.assertPerformanceTiming

Asserts a given [resource timing](https://w3c.github.io/perf-timing-primer/#resource-timing) under a provided budget

![page.assertPerformanceTiming](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCIOaTiazTrGcMbedz%2Fpage.assertPerformaceTiming.png?alt=media\&token=e3f8855f-098e-4f98-aea0-904f8783b258)

## page.assertGaTracking

Asserts a given action was sent to Google Analytics with [analytics.js](https://developers.google.com/analytics/devguides/collection/analyticsjs) or [gtag.js](https://developers.google.com/analytics/devguides/collection/gtagjs). We also assert that sent payloads are valid according to the Google API

![page.assertGaTracking](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuCFgUq_YnWyw_Isc2v%2F-LuCI_wv4zJat1WOhk8R%2Fpage.assertGaTracking.png?alt=media\&token=835a0306-4152-4d97-a9b1-c74f77b278c0)
