Page Commands
Emulates given device metrics and user agent

page.emulate
Defines browser viewport, where the viewport is the user's visible area of a web page

page.setViewport

page.setViewport predefined resolution list

page.setViewport advanced options
Navigates to a given URL and waits until the page loaded

page.goto
Makes a screenshot of the page

page.screenshot

We can select targets to be highlighted on the screenshot

page.screenshot advanced options
Emulates mouse click according to given options

page.click
Moves mouse to given position

page.moveMouse
Emulates tap according to given options

page.tap
Emulates pressing on a key, optionally with modifiers such as ⇧, ⌥, alt, control, ⌘

page.press

page.press advanced options
Scrolls the document in the window by the given amount

page.scroll
Refreshes the page

page.reload
Sets custom user agent

page.setUserAgent
While running test on < 3.0.1 this method requires adding "--no-sandbox --disable-setuid-sandbox" Chromium arguments in Browser options
Sets cookies on the page

page.setCookie

page.setCookie advanced options
Intercepts to a given URL and replaces it according to provided data
As soon as a matching request intercepted the session gets detached, meaning Puppetry stop listening for mocking. You have to set
page.mockRequest
before every request that you want to mock.
page.mockRequest
Waits for a given time before proceeding to the next command

page.waitFor

page.waitForSelector
Waits until a given event before proceeding to the next command

page.waitForNavigation
Waits for HTTP(S) response

page.waitForResponse
Waits for HTTP(S) request

page.waitForRequest

page.authenticate
Evaluates JavaScript code in the page context

page.evaluate
Runs custom JavaScript code in the test suite with use of Puppeteer API and Puppetry API. You can access dynamic environment variables via
ENV
map (e.g. ENV[VAR_NAME]
)
page.runjs
Stops execution of JavaScript, and calls (if available) the debugging function. During test scenarios may happen many things - DOM changes, pages load. It makes hard to figure out why some test assertions fail in some particular moment. You can use this tool to set a breakpoint. Test flow will stop as soon as it reaches this point. So you will be able to examine the page state with DevTools.

page.debug
Listen to dialog events and dismiss or accept dialogs (alert, beforeunload, confirm or prompt) as they are called
The step must be defined before the expected dialog event

page.closeDialog
Assigns template variable dynamically

page.assignVar
Polls
URL
with a given intervals until a response satisfying parserFn
function received or a specified timeout exceeded. It can be used, for example, to retrieve a value from an email sent by the application under test
page.assignVarRemotely
Last modified 3yr ago