Puppetry
3.2.2
3.2.2
  • Welcome Puppetry
  • Getting Started
  • Project
  • Suite
  • Group
  • Target
    • Simple Target
    • iFrame Target
    • ShadowDOM Target
    • Chained Target
    • Shared Target
  • Test Case
  • Test Step / Action
    • Page Commands
    • Page Assertions
    • Target Commands
    • Target Assertions
  • Managing Records
  • Snippets
  • Running tests
    • Interactive Mode
    • Troubleshooting
  • Test Report
  • Export
    • Exporting as Jest Project (CI-friendly)
    • Exporting as Test Specification
  • Settings
  • Template Expressions
  • Testing Techniques
    • Testing Dynamic Content
    • Exhaustive Testing
    • Performance Testing
    • Visual Regression Testing
    • Testing Shadow DOM
    • Testing Google Analytics tracking code
    • Testing Chrome Extensions
    • Testing REST API
    • Mocking HTTP/S Requests
    • Testing Transactional Emails
      • Example with Restmail.net
      • Example with Mailinator
      • Example with IMAP bridge
      • Example with Google API
    • Testing Forms with Captcha
  • Version Control
  • Tips and Tricks
    • Embrace the Power of CSS
  • Command API
  • Test Application
Powered by GitBook
On this page
  • page.emulate
  • page.setViewport
  • page.goto
  • page.screenshot
  • page.click
  • page.moveMouse
  • page.tap
  • page.press
  • page.scroll
  • page.reload
  • page.setUserAgent
  • page.setCookie
  • page.mockRequest
  • page.waitFor
  • page.waitForSelector
  • page.waitForNavigation
  • page.waitForResponse
  • page.waitForRequest
  • page.authenticate
  • page.evaluate
  • page.runjs
  • page.debug
  • page.closeDialog
  • page.assignVar
  • page.assignVarRemotely

Was this helpful?

  1. Test Step / Action

Page Commands

PreviousTest Step / ActionNextPage Assertions

Last updated 4 years ago

Was this helpful?

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

Makes a screenshot of the page

page.click

Emulates mouse click according to given options

page.moveMouse

Moves mouse to given position

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

Sets custom user agent

While running test on < 3.0.1 this method requires adding "--no-sandbox --disable-setuid-sandbox" Chromium arguments in Browser options

page.setCookie

Sets cookies on the page

page.mockRequest

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

Waits for a given time before proceeding to the next command

page.waitForSelector

page.waitForNavigation

Waits until a given event before proceeding to the next command

page.waitForResponse

Waits for HTTP(S) response

page.waitForRequest

Waits for HTTP(S) request

page.authenticate

page.evaluate

Evaluates JavaScript code in the page context

page.runjs

page.debug

page.closeDialog

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

Assigns template variable dynamically

page.assignVarRemotely

Waits for an element matching a provided

Provide credentials for .

Runs custom JavaScript code in the test suite with use of and . You can access via ENV map (e.g. ENV[VAR_NAME])

Stops execution of JavaScript, and calls (if available) the . 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.

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

CSS selector
HTTP authentication
Puppeteer API
Puppetry API
dynamic environment variables
debugging function
email sent by the application under test
page.emulate
page.setViewport
page.setViewport predefined resolution list
page.setViewport advanced options
page.goto
page.screenshot
We can select targets to be highlighted on the screenshot
page.screenshot advanced options
page.click
page.moveMouse
page.tap
page.press
page.press advanced options
page.scroll
page.reload
page.setUserAgent
page.setCookie
page.setCookie advanced options
page.mockRequest
page.waitFor
page.waitForSelector
page.waitForNavigation
page.waitForResponse
page.waitForRequest
page.authenticate
page.evaluate
page.runjs
page.debug
page.closeDialog
page.assignVar
page.assignVarRemotely