# Target Assertions

## target.assertAttribute

Asserts that the specified [attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes) of a target satisfies the given constraint

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZhyLGXpIsxBFSGjMc%2Ftarget.assertAttribute.png?alt=media\&token=fcaa16a6-42a6-40b2-8c69-199615e69505)

## target.assertProperty

Asserts that the specified [property](https://developer.mozilla.org/en-US/docs/Web/API/Element) of a target satisfies the given constraint

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZi-i0BR44ImAPonxI%2Ftarget.assertProperty.png?alt=media\&token=baae6cb3-2a19-47f0-ac31-069565ceba77)

## target.assertVisible

Asserts that the element is currently visible in the current viewport ([intersecting](https://pptr.dev/#?product=Puppeteer\&version=v1.15.0\&show=api-elementhandleisintersectingviewport), styles `display` is not `none`, `visible` is not `hidden`, `opacity` is not `0`)

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZi1xO1JvslB09UbNl%2Ftarget.assertVisible.png?alt=media\&token=da31cc61-b517-4d6b-98b9-4e1de1b7591a)

## target.assertHtml

Asserts that the HTML content of the focused element satisfies the given constraint

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZmcRhNnLN4fwKX_G7%2F-LhZtdvwZ_xBklQjTx3u%2Ftarget.assertHtml.png?alt=media\&token=67cf2316-45a2-4a75-8f96-3ba94f624a5c)

## target.assertBoundingBox

Asserts that the [bounding box](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) (size and position) of a target satisfies the given constraint

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiCSzQEc9x2kgk3kJ%2Ftarget.assertBoundingBox.png?alt=media\&token=2fbc41ad-867b-4ed4-963d-f4f336d7d05a)

## target.assertPosition

Asserts that target's position relative to other given target

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiG0O5DwM8cRcp-eM%2Ftarget.assertPosition.png?alt=media\&token=47710152-44d5-4922-a528-8a4e1e57c8f7)

## target.assertStyle

Asserts that the [computed style](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) of a target matches the given value

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiKbc3gj6fjF-Ynw8%2Ftarget.assertStyle.png?alt=media\&token=5c980786-ff0e-40f4-baff-2127f67e13f0)

## target.assertMatchesSelector

Asserts that a target matches a given selector or pseudo-selector

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiNp44w_A8uvTQSIq%2Ftarget.assertMatchesSelector.png?alt=media\&token=a1950a9d-3c61-4c40-bbbe-3b56199734af)

## target.assertNodeCount

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

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LjpyPM85qx6L032UZzr%2F-LjpyfhTPeiI6krgboXz%2Ftarget-assertNodeCount.png?alt=media\&token=a89952dc-0f72-4550-95de-a4629030cb0d)

## target.assertTextCount

Asserts that number of child elements containing a specified text satisfies the given constraint.

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LjpyPM85qx6L032UZzr%2F-LjpywrnQsTUpFSWPMCR%2Ftesrget-assert-text-count.png?alt=media\&token=05183c87-12db-410e-9cd1-0b265c1e7ddf)

## target.assertContainsClass

Asserts that the specified class value exists in the [element's class attribute](https://developer.mozilla.org/en-US/docs/Web/API/Element).

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiQR2Pl08Yui8r2Fs%2Ftarget.assertContainsClass.png?alt=media\&token=7d15a0c2-71bf-4a6c-8993-9cd9ccff1714)

## target.assertScroll

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

![](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhZhvgo3HnB9XjGRqw_%2F-LhZiTgawNn4IzCNn5CS%2Ftarget.assertScroll.png?alt=media\&token=fdd25af4-07fc-4488-9793-02a1800968dd)
