> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# switchTab

> Switch the active tab by index, URL substring, or URL regex.

Provide exactly one of `substring`, `regex`, or `index`. The simplified form is
a substring (string) or an index (number).

## Parameters

| Parameter     | Type               | Required | Description                                                                                                                                            |
| ------------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `substring`   | `string`           | No       | Match the URL by substring.                                                                                                                            |
| `regex`       | `string`           | No       | Match the URL by regular expression.                                                                                                                   |
| `index`       | `number \| string` | No       | Zero-based tab index.                                                                                                                                  |
| `timeout`     | `number`           | No       | Maximum milliseconds to keep retrying failed switches. Defaults to `browser.smartWaitingTimeoutMs`.                                                    |
| `loadTimeout` | `number`           | No       | Maximum milliseconds for each selected tab load. Defaults to `timeout` for backwards compatibility and never reduces the configured page load timeout. |

Both timeout values must be whole seconds expressed in milliseconds, from `0` to
`60000`. A switch always gets at least two attempts. `timeout` controls whether
further attempts start; it does not reload the target page or cancel an attempt
already in progress. Existing steps with only `timeout` keep using it as their
load timeout as well, so their serialized form and runtime behavior remain
compatible.

The effective load timeout is the larger of `loadTimeout` (or its legacy
`timeout` fallback) and `browser.pageLoadTimeoutMs`. This lets you use a short
retry window to stop looking for a missing tab without also making an existing
tab more likely to fail while loading.

## Shorthand

Substring (string) or zero-based index (number).

```yaml theme={null}
- switchTab: 1
```

The shorthand cannot include timeouts. Setting either timeout uses the detailed
form:

```yaml theme={null}
- switchTab:
    index: 1
    timeout: 5000
    loadTimeout: 30000
```

## Examples

```yaml theme={null}
- switchTab:
    substring: /companies/momentic/jobs/938G5qp
    timeout: 5000
    loadTimeout: 15000
```

```yaml theme={null}
- switchTab:
    substring: randomly-changing-link
```

```yaml theme={null}
- switchTab:
    regex: practice-tab-search
```

```yaml theme={null}
- switchTab: 1
```

## Related

* [YAML format](/docs/core-concepts/test-format)
