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

# TestMode

> Reference for WEBSALE test mode actions used to activate, deactivate and switch the shop's test mode for staged previews and debugging.

This section describes the available actions in the test mode area. With these actions, test mode can be activated, deactivated, and switched.

***

## Actions overview

| **Action**       | **Description**                |
| ---------------- | ------------------------------ |
| `TestModeOn`     | Activates test mode.           |
| `TestModeOff`    | Deactivates test mode.         |
| `TestModeChange` | Switches the active test mode. |

***

## Actions

### TestModeOn

This action activates test mode. The user must provide the configured test mode password.

**Usage example**\
Can be used on the test mode page (`testMode.htm`), through which shop operators or testers can activate test mode with a password to see test-specific content.

**Parameters**

| **Name**   | **Description**                               |
| ---------- | --------------------------------------------- |
| `password` | The password for activating test mode.        |
| `debug`    | Activates extended debugging (value: "`on`"). |

**Error codes**

| **Error code**    | **Description**                      |
| ----------------- | ------------------------------------ |
| `missingPassword` | Parameter `password` is missing.     |
| `invalidPassword` | The specified password is incorrect. |

**Related modules, variables & methods**

* [\$wsTestMode](/en/frontend/referenz/module/wstestmode)
* [\$wsTestMode.active](/en/frontend/referenz/module/wstestmode#\$wstestmode-active)
* [\$wsTestMode.debug](/en/frontend/referenz/module/wstestmode#\$wstestmode-debug)

**Example** showing how test mode is activated via a password form, optionally with debugging.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $cActionTestModeOn = $wsActions.create("TestModeOn") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionTestModeOn.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionTestModeOn.id }}">
    <input type="hidden" name="wstarget" value="/">
    <input type="password" name="password">
    <input type="checkbox" name="debug" value="on"{{ if $wsTestMode.debug }} checked{{ /if }}>
    <button type="submit">Activate test mode.</button>
</form>
```

***

### TestModeOff

This action deactivates test mode and the shop returns to normal live operation.

**Usage example**\
Can be used on the test mode page or in the shop header to deactivate test mode directly in the shop.

**Related modules, variables & methods**

* [\$wsTestMode](/en/frontend/referenz/module/wstestmode)
* [\$wsTestMode.active](/en/frontend/referenz/module/wstestmode#\$wstestmode-active)

**Example** showing how test mode is deactivated via a button.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionTestModeOff = $wsActions.create("TestModeOff") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionTestModeOff.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionTestModeOff.id }}">
    <input type="hidden" name="wstarget" value="/">
    <button type="submit">Deactivate test mode.</button>
</form>
```

***

### TestModeChange

This action switches the active test mode without completely deactivating it. This is useful when multiple test modes are configured.

**Usage example**\
Can be used on the test mode page when different test scenarios or configurations are available in parallel and you want to switch between them.

**Parameters**

| **Name** | **Description**                                              |
| -------- | ------------------------------------------------------------ |
| `debug`  | Activates or deactivates extended debugging (value: "`on`"). |

**Error codes**

| **Error code**    | **Description**                      |
| ----------------- | ------------------------------------ |
| `invalidPassword` | The specified password is incorrect. |

**Related modules, variables & methods**

* [\$wsTestMode](/en/frontend/referenz/module/wstestmode)
* [\$wsTestMode.active](/en/frontend/referenz/module/wstestmode#\$wstestmode-active)
* [\$wsTestMode.debug](/en/frontend/referenz/module/wstestmode#\$wstestmode-debug)

**Example** showing how the debug setting of the active test mode is changed.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionTestModeChange = $wsActions.create("TestModeChange") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionTestModeChange.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionTestModeChange.id }}">
    <input type="hidden" name="wstarget" value="/">
    <input type="checkbox" name="debug" value="on"{{ if $wsTestMode.debug }} checked{{ /if }}>
    <button type="submit">%%SaveSettings%%</button>
</form>
```
