---
schema_version: "1"
id: 6eff3073e8e8a26b80f59abb8b5cd0f860a1ee99f3a7aad25bbf685e7df6fade
title: document, navigation, and window Objects
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/utam/references/descriptions-metadata.md
canonical_url: https://developer.salesforce.com/docs/platform/utam/references/utam-grammar/descriptions-metadata.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4627658ed826001cf0195d22661f351130cb014db844f74b85653595135451a9
products:
  - UI Test Automation Model
  - lwc
---
# document, navigation, and window Objects

The `document` and `navigation` objects can be used as an element in a compose statement.

## document object

The `document` object exposes methods to interact with the DOM, such as waiting until its state is ready or checking the URL. It also exposes methods for frames.

Reference the `document` object inside a compose statement in JSON using this syntax:

```json
{
  "element": "document",
  "apply": "getUrl"
}
```

Here are the supported methods for the `document` object. The return value is asynchronous. For example, in JavaScript, a Promise is returned.

| Method                              | Description                                                                      | Returns               | Example                                          |
| ----------------------------------- | -------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------ |
| `waitFor<T>`                        | Waits for specified criteria to be satisfied.                                    | `<T>`                 | [beforeLoad](/grammar/explicit-waits#beforeload) |
| `waitForDocumentReady()`            | Waits for the document to be ready for JavaScript code to execute.               | `boolean`             | [beforeLoad](/grammar/explicit-waits#beforeload) |
| `containsElement(locator: Locator)` | Checks whether the document contains an element with a matching selector.        | `boolean`             | [Explicit Waits](/grammar/explicit-waits)        |
| `getUrl()`                          | Gets the URL of the document.                                                    | `string`              |                                                  |
| `enterFrame`                        | enters a frame or iframe element                                                 | `frame`               |                                                  |
| `enterFrameAndLoad`                 | enters a frame or iframe element and then loads a Page Object that is a new root | `frame`, `pageObject` |                                                  |
| `exitFrame`                         | exits focus from a current frame or iframe                                       |                       |                                                  |
| `exitToParentFrame`                 | exits focus from a frame or iframe to the immediate parent frame                 |                       |                                                  |

## navigation object

The `navigation` object exposes methods for browser navigation, such as back and forward, as well as methods
for managing multiple browser windows or tabs.

Reference the `navigation` object inside a compose statement in JSON using this syntax:

```json
{
  "element": "navigation",
  "apply": "back"
}
```

Here are the supported methods for the `navigation` object.
| Method | Description | Returns |
| ---------------------------- | ------------------------------------------------------ | --------- |
| `back` | Browser navigates backward | void |
| `forward` | Browser navigates forward | void |
| `switchToWindow(url)` | Switches to the window navigated to the specified URL | `window` |
| `closeWindow(url)` | Closes the window navigated to the specified URL; if no URL is specified, closes the current window | void |
| `closeWindow()` | Closes the current window | void |
| `getWindowCount` | Gets the number of currently opened managed windows | `integer` |
| `currentWindow` | Gets the window with the current command context | `window` |
| `setupWaitForNewWindow` | Sets up a wait for a new window to appear after taking a subsequent action | void |
| `waitForNewWindow` | Waits for a new window to be opened and switches the command context to the new window; if called without a prior call to `setupWaitForNewWindow`, an exception is thrown | `window` |
| `waitForNewWindowAndLoad` | Waits for a new window to be opened, switches to it, and loads a Page Object that is a new root | `pageObject` |
| `switchToWindowAndLoad(url)` | Switches to the window navigated to the specified URL and loads a Page Object that is a new root | `pageObject` |

## window object

The `window` object exposes methods for manipulating a single browser window or tab.

Here are the methods for the `window` object.
| Method | Description | Returns |
| --------------- | ---------------------------------------------------- | ---------- |
| `getRect` | Gets the rectangle of the window | `rect` |
| `setRect(rect)` | Sets the rectangle of the window | void |
| `close` | Closes the window | void |
| `getDocument` | Gets the document object associated with this window | `document` |
