# Create Salesforce test cases

> Create a test case for a Salesforce org, write its steps with Salesforce steps, check them with Copilot, and run them through the project's Salesforce connection.

The project needs a Salesforce connection before Salesforce steps can sign in. See [Salesforce connections](https://testsigma.com/docs/arcus/v2/apps/salesforce/connect-and-sync/).

Create a test case for a Salesforce org, write its steps with Salesforce steps, and check them in a Copilot session against the connected org. Salesforce test cases run in a browser, so you author and run them with **Web**, and pick the org in **Salesforce connection**.

## Create the test case

1. Open **Test Cases** in the left navigation and open the folder the test case belongs in.
2. Click **Create**, or press `C`. The dialog opens with **Documentation** selected as the template type and the folder you opened in the folder chip.
3. Enter a title and, optionally, a description.
4. If the folder chip reads **Select a Folder**, click it, select a folder, and click **Select Folder**. Without a folder, Arcus shows "Folder is Required" and doesn't create the test case.
5. Click **Create**. The test case opens on the **Details** tab.

For the template types and the other properties in the dialog, see [Manage test cases](https://testsigma.com/docs/arcus/v2/create-and-manage/test-cases/#create-a-test-case). Only test cases with the status **Ready** can be added to test runs and run templates.

## Write the steps

1. Open the **Automated steps** tab and click **Write the script manually**. The step editor opens.
2. In the first step row, type `salesforce` and select **salesforce/log in and open app**. Arcus inserts the step group **Log in to Salesforce and open the standard__LightningSales app**, which signs in through the connection and opens the Sales app.

   ![The step list filtered by salesforce, with salesforce/log in and open app outlined among the Salesforce step groups.](https://s3.amazonaws.com/static-docs.testsigma.com/arcus/application_types/apps_salesforce_step_picker.webp)

3. Add the steps for the test, such as **Navigate to a Salesforce tab**, **Click Save in Salesforce**, and **Verify page**. To find a Salesforce step, type what you want to do, such as `salesforce` or `field`.

   ![A Salesforce test case's steps, with the sign-in step group outlined.](https://s3.amazonaws.com/static-docs.testsigma.com/arcus/application_types/apps_salesforce_steps.webp)

For every Salesforce step and step group, and a complete example, see [Salesforce test steps](https://testsigma.com/docs/arcus/v2/apps/salesforce/steps/).

Recording a sign-in saves what you type on Salesforce's login page, including the password, as plain text in the steps. Sign in with `salesforce/log in and open app` instead.

## Check the steps with Copilot

If the connection shows **Needs re-auth**, Salesforce no longer accepts its login, and the session fails before the first step runs. Re-authorize it first: in **Project Settings** > **Salesforce**, click the ellipsis icon (⋯) on the connection and click **Re-authorise**.

1. On the test case, click **Debug with Copilot**. The **Copilot configuration** panel opens.
2. In **What you are authoring**, select **Web**.
3. In **Where to run**, select **My local machine** or **Cloud**.
4. Under **Test machine**, choose the browser.
5. Under **Salesforce**, select the org in **Salesforce connection**. Each connection shows its name, its type, and its health, such as **Needs re-auth**. The panel reads "The session logs in to this org when a step needs Salesforce."

   ![The Salesforce section of the Copilot configuration panel, with the Salesforce connection field outlined.](https://s3.amazonaws.com/static-docs.testsigma.com/arcus/application_types/apps_salesforce_copilot_connection.webp)

6. Click **Start Copilot**.

**Click New on a Salesforce object**, **Open the create record form of a Salesforce object**, and **Enter a value in a Salesforce field** are inserted with **Account** as a placeholder. Change the object and field in the step after you insert it, or click the step's target in the session, click **Pick from page**, and click the field or button in the browser. See [Salesforce test steps](https://testsigma.com/docs/arcus/v2/apps/salesforce/steps/#limitations).

If a step fails, fix it, then click the ellipsis icon (⋯) on the step and click **Run from here**. Your changes save to the test case.

## Run the test case

Add the test case to a [test run](https://testsigma.com/docs/arcus/v2/run-tests/test-runs/#create-a-test-run) or a [run template](https://testsigma.com/docs/arcus/v2/run-tests/test-runs/#create-a-run-template) with a run configuration for **Web**. In the run configuration, select the org in **Salesforce connection** under **Salesforce**. Runs sign in to this org when they start, even if no step uses Salesforce, and fail before the first step if the connection can't sign in. See [Web configurations](https://testsigma.com/docs/arcus/v2/run-tests/run-configurations/#web-configurations).

If the run configuration names no connection, runs with Salesforce steps sign in with the project's default connection.
