goTo
The goTo action navigates the browser to a specified URL. This is typically used to start a test at a specific page or navigate between pages during a test.
You can specify the target URL directly as a string, or use an object for more options:
- String Shorthand: Provide the full URL, a path (starting with
/), or a variable reference directly as the value for thegoTokey. If a path is provided, it navigates relative to the current URL or the globaloriginif set in the configuration. - Object Format: Use an object with the following properties:
url: (Required) The URL to navigate to. Can be a full URL, a path, or a variable reference.origin: (Optional) Protocol and domain prepended tourlwhenurlis a path. Overrides the globaloriginif set.params: (Optional) Query parameters to append to the resolved URL. Merged with config-leveloriginParams.surface: (Optional) The browser (session, window, or tab) to navigate. Omit to navigate the active tab. Naming a browser that isn’t open yet opens it. To open a browser with explicit launch options (headless, window size, viewport) before navigating, usestartSurface.newTab/newWindow: (Optional) Open the URL in a new tab or window instead of navigating the current one.goTois the only action that opens tabs and windows.
For comprehensive options, see the
goToreference.
Examples
Here are a few ways you might use the goTo action:
Navigate to a full URL (string shorthand)
Navigate to a relative path (string shorthand)
Assumes the browser is currently at https://example.com or a global origin is set.
Navigate using an object with a full URL
Navigate using an object with a relative path and specific origin
Query parameters
You can append query parameters to a URL using the params option. This is useful for authentication tokens or tracking parameters.
- Step-level
params: An object specifying query parameters to append to the URL. Applies to all URLs, both relative and absolute. Values support environment variable substitution with$VARsyntax. - Config-level
originParams: Default query parameters in your configuration file that apply to relative URLs resolved againstorigin. Step-levelparamsmerge on top, with step keys taking precedence on collision.
When your URL contains a fragment such as /page#section, query parameters are inserted before the fragment, giving /page?token=value#section.
Values in params and originParams are embedded directly in request URLs and appear in test results, logs, and reports. Avoid storing long-lived secrets in these fields.
Append query parameters to a URL
Use config-level default parameters
Set originParams in your configuration file to avoid repeating parameters on every step. For example, when testing a Clerk-protected application, set the testing token once:
Configuration file:
Test specification:
Tabs, windows, and browsers
goTo is the only action that opens new tabs, windows, and browsers. Name what you open, then any later step can act in it with a surface reference.
newTab: Open the URL in a new tab of the target window and focus it.trueopens an anonymous tab; a string (or{ "name": … }) names the tab.falsedisables.newWindow: Open the URL in a new window and focus it.true, a name string, or{ "name": …, "tab": … }, wheretabnames the window’s first tab.falsedisables.newTabandnewWindoware mutually exclusive on one step.surface: Without an opener, this selects the browser, window, or tab to navigate. It opens the browser if it isn’t running yet. WithnewTab, it selects the window the tab opens in.
Open a second browser
Open a named tab, then act in it
Open a named window with a named first tab
Navigate an existing tab or window
See Test across multiple tabs, windows, and browsers for the full selector grammar. It covers names, indexes, -1 for newest, and title and URL criteria. It also covers addressing tabs a page opens itself, and driving multiple browsers at once.
Wait conditions
The goTo action supports advanced waiting conditions after navigation to ensure pages are fully loaded and ready before the next step runs.
When using the object format, you can configure:
timeout: (Optional) Maximum time in milliseconds to wait for all conditions to be met. If exceeded, the goTo action fails (default: 30000).waitUntil: (Optional) Object specifying conditions to wait for:networkIdleTime: (Optional) Wait for network activity to be idle, meaning no new requests, for this duration in milliseconds. This check always runs and you can’t skip it. Set it to0to treat the page as network-idle as soon as the first check completes, rather than waiting for a quiet period. Defaults to500.domIdleTime: (Optional) Wait for DOM mutations to stop for this duration in milliseconds. This check always runs; you can’t skip it. Set it to0to treat the DOM as stable as soon as the first check completes rather than waiting for a quiet period (default: 1000).
find: (Optional) Wait for a specific element to be present in the DOM. At least one ofselectororelementTextmust be specified.selector: (Optional) CSS selector for the element to wait for.elementText: (Optional) Display text of the element to wait for. Doc Detective matches this against the element’s full visible text with whitespace normalized, so text that a framework splits across several nodes still matches. To match a substring with a regular expression instead of the whole text, wrap the value in slashes (/pattern/). See How text matching works.
Wait for network idle
Navigate to a page and wait for network activity to settle.
Wait for a specific element
Navigate to a dashboard and wait for a specific element to appear.
Wait for element with text
Wait for an element with specific text to appear.
Combine multiple wait conditions
Use multiple wait conditions together with a custom timeout.