> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/troubleshooting.md). Agents can also search and read this documentation through its [MCP server](https://coldbox.ortusbooks.com/~gitbook/mcp).

# Troubleshooting

Fix common browser testing problems: skipped specs, login 404s, wrong route paths, timeouts and browsers that do not start.

Start with `bxplaywright doctor`: it checks the driver, Node.js and the installed browsers. Then find your symptom below.

## Every Browser Spec Is Skipped

The browser methods skip the running spec with a reason when browser testing is not available. Read the reason in the skipped spec:

| Reason                                                            | Fix                                                                                                                                                                                                                                               |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Browser specs need the BoxLang engine`                           | The tests run on Lucee or Adobe ColdFusion. Run them on BoxLang, or exclude your browser folder on other engines (see [Setup](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/setup.md#running-on-several-engines)) |
| `bx-playwright is not installed: install-bx-module bx-playwright` | The module is missing in the runtime **that runs the tests**. For a CommandBox server, install it in the server, then restart it                                                                                                                  |

## browse() Is Not Defined

An error saying that `browse()`, `browserAvailable()` or `this.playwright()` does not exist means TestBox did not attach browser support to the spec:

* **The browser annotation is missing.** Add `@browser`, `@browserProfile` or `@baseURL` on the lines above `class`, on the spec or a class it extends. Extending `BaseTestCase` alone does not turn browser support on.
* **Your TestBox release has no annotation-driven browser support.** Browser specs need a TestBox release with [TestBox#222](https://github.com/Ortus-Solutions/TestBox/pull/222). On older releases the annotations do nothing and `browse()` is not defined. Update TestBox (see [Setup](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/setup.md#requirements)).
* **The engine is not BoxLang.** The runner only attaches browser support on BoxLang.

To see why browser testing is not available on a spec that has the methods, call `getBrowserSupport().getUnavailableReason()`.

## The Bundle Does Not Compile on CFML

Browser specs are BoxLang classes (`.bx`). A bundle written in BoxLang cannot load on a CFML engine, so the runner reports an error instead of a skip. Keep browser specs in their own folder and exclude it on CFML engines, like the ColdBox platform does in its `tests/runner.cfm`.

## Executable Doesn't Exist / Browser Fails to Start

The browser is not installed, or its system libraries are missing:

```bash
bxplaywright install chromium
# Linux, CI or containers: also install the operating system libraries
bxplaywright install chromium --with-deps
```

The browsers live in `~/.boxlang/playwright` of the user that **runs the tests**. If your server runs as another user (a service account, a container), install them as that user, or point both to the same folder with the `BX_PLAYWRIGHT_HOME` environment variable.

## The Saved Session Is Not Logged In

* Does the setup closure really log in? End it with an assertion, such as `expect( page ).toSee( "Dashboard" )`, so a failed login fails there instead of in every spec.
* Did the session expire on the server? A saved session never expires by default: pass `maxAge` (minutes) below your application session timeout, or `refresh : true`. See [Authentication](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/authentication.md#reusing-and-refreshing-sessions).
* Do the setup and the specs use the same host? A cookie set for `127.0.0.1` is not sent to `localhost`. Use one host name in `baseURL` and your SES base URL.
* Did you pass the session? Only `browse()` calls with `{ session : "name" }` start logged in.

## Route Paths Are Wrong

`visitRoute()` lands on a 404 page, or `assertRouteIs()` fails with a path that has an extra or missing prefix such as `/index.cfm`.

`routeURL()` builds paths from the web root, from the SES base URL of the **virtual** application without its `appMapping`. When the app is served from a sub folder, add the `webMapping` annotation to the spec (`@webMapping( "/shop" )`). When the server under test uses another prefix, set the one the browser needs in a `beforeEach()`:

```javascript
beforeEach( ( currentSpec ) => {
	getRequestContext().setSESBaseURL( "http://127.0.0.1:8080/index.cfm" )
} )
```

Check what a route builds with `debug( routeURL( "users.show", { id : 5 } ) )`.

## No ColdBox Application

`BaseTestCase.NoColdBoxApp: The route helpers need a loaded ColdBox application`

The route helpers read the routes of the application your spec loads. Extend `coldbox.system.testing.BaseTestCase` (or `BaseIntegrationTest`) and keep `loadColdbox` on. A `BaseModelTest`, or a test with `loadColdbox=false`, has no routes.

## Unknown Named Route

`InvalidArgumentException: The named route 'users.show' does not exist`

The route name is not registered in the virtual application: check the spelling, the `.as()` name in your router, and for module routes the `name@module` or `module:name` form with the module name (not its entry point).

## Timeouts

A matcher or `assertRouteIs()` waits up to the bx-playwright assertion timeout (5 seconds by default), actions and navigation up to 30 seconds. A timeout usually means the page never reached the expected state: open the trace (see [Artifacts & Debugging](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/artifacts-and-debugging.md)) before raising the timeouts. If the application is really slow, raise them in the bx-playwright `timeouts` setting or a custom profile.

## Matchers Are Not Found

`toSee()` and the other browser matchers are registered by TestBox for every bundle with a browser annotation (see [browse() Is Not Defined](#browse-is-not-defined)). In a spec without one, register them yourself:

```javascript
addMatchers( new testbox.system.browser.BrowserMatchers() )
```

## The Browser Stays Open or Specs Interfere

* Use `this.playwright()`, not `playwright()`, to reach the bundle manager. The bare `playwright()` BIF creates a new manager that the bundle does not close.
* Do not use `asyncAll` in suites that browse: browser specs are not thread safe.
* Each `browse()` call gets new pages and contexts. If state leaks between specs, it lives in your application (database, cache, application scope), not in the browser.

## See Also

* [Setup](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/setup.md)
* [Authentication](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/authentication.md)
* [Artifacts & Debugging](https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/artifacts-and-debugging.md)
* [bx-playwright Errors](https://bxplaywright.boxlang.io/errors/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://coldbox.ortusbooks.com/the-basics/testing-quick-start/browser-testing/troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
