> For the complete documentation index, see [llms.txt](https://docs.puppetry.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.puppetry.app/master/test-step/commands.md).

# Page Commands

## page.emulate

Emulates given device metrics and user agent

![](/files/-LhUyMBtfJ0IfdmCp_4I)

## page.setViewport

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

![](/files/-LhUyOY2S1qqLTgqyhXw)

## page.goto

Navigates to a given URL and waits until the page loaded

![](/files/-LhUyR23MNONHrVErv2j)

## page.moveMouse

Moves mouse to given position

![](/files/-LhUyTWiooE47Q80O5vH)

## page.click

Emulates mouse click according to given options

![](/files/-LhUyVrzTKDMJfAeWt7l)

## page.tap

Emulates tap according to given options

![](/files/-LhUyZxS3TiF7KvXjgUo)

## page.press

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

![](/files/-LhUybm0h_BJKNrMHcHi)

## page.scroll

Scrolls the document in the window by the given amount

![](/files/-LhVFQdCoSeHpP9RX_ar)

## page.reload

Refreshes the page

![](/files/-LhVGqprGsB1DV3cw4AF)

## page.setCookie

Sets cookies on the page

![](/files/-LhZm5RauduHMsexhnC-)

![](/files/-LhZm7FLwTvQBI4oqAhk)

## page.waitFor

Waits for a given time before proceeding to the next command

![](/files/-LhVGIp96ME32Yb-3Hlx)

## page.waitForSelector

Waits for an element matching a provided [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors)

![](/files/-LhVGMzXrOcsx8990krh)

## page.waitForNavigator

Waits until a given event before proceeding to the next command

![](/files/-LhVGQ5Q52lBJ-fyMNDJ)

## page.evaluate

Evaluates JavaScript code in the page context

![](/files/-LhVGTC6jvVOzWXR0ZEz)

## page.runjs

Runs custom JavaScript code in the test suite with use of [Puppeteer API](https://pptr.dev) and [Puppetry API](https://docs.puppetry.app/command-api). You can access [dynamic environment variables](https://docs.puppetry.app/template) via `ENV` map (e.g. `ENV[VAR_NAME]`)

![](/files/-LhVGV_ZO9UHydwZPnFb)

## page.debug

Stops execution of JavaScript, and calls (if available) the [debugging function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger). 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.

![](/files/-LhVGYBFl8xEhObFsGYA)

## page.assignVar

Assigns template variable dynamically

![](/files/-LhVGa5vNcopG4IZ3QuK)

## 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](https://docs.puppetry.app/testing-emails)

![](/files/-LhVGkSPTzT11H032LVg)

![](/files/-LhVGdAm_OoJXcqNQhyJ)
