Command API
API available via page.runjs command
Puppeteer methods
bs - object representing browsing session
browser - instance of Browser, which is being created in test
setup
with configuration provided in Puppetry apppage - instance of Page (alias of
bs.browser.page
)target(
element: ElementHandle
) - helpersgetProp(prop: string): Promise<string>
- obtain element property valuegetAttr(attr: string): Promise<string>
- obtain element attribute valueisVisible(): Promise<boolean>
- find out f element visibleselect(value: string): Promise<void>
- set a value on select element
Examples:
Working with targets
Assuming we have targets SUBMIT_BTN
, EMAIL_INPUT
defined with Puppetry app
Jest tools
Please find available API in official documentation of Jest framework. Most demanded tool for the context is expect. In the scope of the test it is extended with the following methods:
expect( result )
toBeOk( expectedValue, assertionSource)
- assert the received value is truthytoBeEqual( expectedValue, assertionSource)
- assert the received value equals expected onetoIncludeSubstring(expectedSubstring, assertionSource)
- assert the received string contains expected onetoPassCondition(operator, valueToCompare, assertionSource)
- assert the received value satisfies a given Puppetry conditiontoMatchBoundingBoxSnapshot(snapshot, assertionSource)
- assert the received bounding box matches a given snapshottoMatchPosition(position, target, counterpart, assertionSource)
- assert the received position object matches a given one
Examples:
Helpers
Helpers are functions available in specification (suite) scope
util
png - build screenshot option
pollForValue - poll for value (used by
page.assignVarRemotely
)exp - template expressions functions
fetch - Node.js-implementation of window.fetch
localStorage - Node.js-implementation of localStorage
png( title, options ): Object
- build screenshot options
Example:
This command saves screenshot in ./screenshots/All--available--methods/Just-for-test.png
given that test title is All available methods
Node.js
In the test scope one can access Node.js modules.
Last updated