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 URL directly as the value for the
goTokey. Use an absolute URL, a path that starts with one/, or a value that starts with a variable, such as$BASE_URL/docs. Doc Detective joins a path to the globaloriginfrom the configuration. - Object Format: Use an object with the following properties:
url: (Required) The URL to navigate to, in the same three forms.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
The docs tests run the two full-URL examples below and the ID, class, or attribute example under Wait conditions. The other examples on this page are illustration-only. The relative-path examples depend on the current page or a configured origin.
Navigate to a full URL (string shorthand)
Navigate to a relative path (string shorthand)
Assumes a global origin, such as https://example.com, is set in the configuration. Without an origin, the step fails.
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.
Doc Detective embeds params and originParams values in request URLs. A value you write directly in these fields appears in test results, logs, and reports. To keep a secret out of output, reference an environment variable, such as "token": "$API_TOKEN". The request uses the real value, and output shows ***API_TOKEN***. See Keep secrets out of logs, reports, and captures.
Append query parameters to a URL
Append a testing token to a dashboard path using step-level params.
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 second, named browser session for the administrator account, then select a browser by its bare engine keyword.
Open a named tab, then act in it
Open the checkout in a named tab, then target that tab by name from a later step.
Open a named window with a named first tab
Open the administrator console in its own window and name its first tab.
Open an anonymous tab or window
Set newTab or newWindow to true to open and focus a new tab or window without naming it. Later steps then act on it as the active surface. Name it instead when a later step needs to select it by name.
Navigate an existing tab or window
Navigate an already-open window by naming it in surface.
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 element-finding field must be specified.selector: (Optional) The CSS selector or XPath selector of 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.elementId: (Optional) ID attribute of the element. Supports exact match or a regex pattern using/pattern/syntax.elementTestId: (Optional)data-testidattribute of the element. Supports exact match or a regex pattern using/pattern/syntax.elementClass: (Optional) Class, or array of classes, the element must have. Each class supports exact match or a/pattern/regex. The element must have all specified classes.elementAttribute: (Optional) Object of attribute key-value pairs the element must have. Values can be strings (supporting/pattern/regex), numbers, or booleans. Booleantruematches attribute presence, andfalsematches absence.elementAria: (Optional) Computed accessible name of the element per the ARIA specification. Supports exact match or a/pattern/regex.
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.
Wait for an element by ID, class, or attribute
waitUntil.find accepts the same element-finding fields as find: selector, elementText, elementId, elementTestId, elementClass, elementAttribute, and elementAria. Each matches an exact value or a /regex/ pattern. Set several fields to wait for an element that matches all of them.
Treat the page as idle immediately
Set networkIdleTime or domIdleTime to 0 to treat the page as idle once the first check completes, rather than waiting for a quiet period. Both checks always run, and you can’t skip them.