Command API
API available via page.runjs command
Last updated
Was this helpful?
API available via page.runjs command
Last updated
Was this helpful?
Modules "fs", "path" and "os" exposed with the corresponding variables.
bs - object representing browsing session
browser - instance of , which is being created in test setup
with configuration provided in Puppetry app
page - instance of (alias of bs.browser.page
)
performance
resources - array with network activity logs
getGaTracking - log of Google Analytics beacons
getTarget - get target by name
getTargetOrFalse - the same as previous, but when target is not available in the DOM return false instead of throwing exception
target(element: ElementHandle
) - helpers
getProp(prop: string): Promise<string>
- obtain element property value
getAttr(attr: string): Promise<string>
- obtain element attribute value
isVisible(): Promise<boolean>
- find out f element visible
select(value: string): Promise<void>
- set a value on select element
Examples:
Assuming we have targets SUBMIT_BTN
, EMAIL_INPUT
defined with Puppetry app
expect( result )
toBeOk( expectedValue, assertionSource)
- assert the received value is truthy
toBeEqual( expectedValue, assertionSource)
- assert the received value equals expected one
toIncludeSubstring(expectedSubstring, assertionSource)
- assert the received string contains expected one
toPassCondition(operator, valueToCompare, assertionSource)
- assert the received value satisfies a given Puppetry condition
toMatchBoundingBoxSnapshot(snapshot, assertionSource)
- assert the received bounding box matches a given snapshot
toMatchPosition(position, target, counterpart, assertionSource)
- assert the received position object matches a given one
Examples:
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
bytesToString - translates size into human-readable string
generateTmpUploadFile - creates a file in temporary directory by given name and size
png( id, parentId, screenshotTitle, 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
Please find available API in . Most demanded tool for the context is expect. In the scope of the test it is extended with the following methods:
fetch - of window.fetch
localStorage - of localStorage
In the test scope one can access .