Page Commands

page.emulate

Emulates given device metrics and user agent

page.setViewport

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

page.goto

Navigates to a given URL and waits until the page loaded

page.moveMouse

Moves mouse to given position

page.click

Emulates mouse click according to given options

page.tap

Emulates tap according to given options

page.press

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

page.scroll

Scrolls the document in the window by the given amount

page.reload

Refreshes the page

page.setCookie

Sets cookies on the page

page.waitFor

Waits for a given time before proceeding to the next command

page.waitForSelector

Waits for an element matching a provided CSS selector

page.waitForNavigator

Waits until a given event before proceeding to the next command

page.evaluate

Evaluates JavaScript code in the page context

page.runjs

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.debug

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.assignVar

Assigns template variable dynamically

page.assignVarRemotely

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

Last updated