> For the complete documentation index, see [llms.txt](https://learning.contextqa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learning.contextqa.com/packaged-application-testing/salesforce-testing/test-generation-and-execution.md).

# Test Generation & Execution

Recording Salesforce test cases in ContextQA, managing test data with profiles and parameters, and running tests in parallel with execution logs.

> **Documentation owner:** [Deep Barot](https://contextqa.com/academy/) · **Last updated:** November 12, 2026

## Quick answer

Create a Salesforce case by recording an authorized browser journey or generating steps from reviewed requirements. Add a reusable role-specific login prerequisite, parameterize synthetic data, run the case, and verify its execution evidence and saved record state. Group reviewed cases into plans for repeatable regression.

## Key takeaways

* Recording Salesforce test cases in ContextQA, managing test data with profiles and parameters, and running tests in parallel with execution logs.
* The two course segments show how a reusable Salesforce test is authored and then run.
* ContextQA creates test cases by recording your interactions with the Salesforce UI.

## What this page covers

{% hint style="info" %}
**Who is this for?** SDETs and QA managers who need to record, parameterize, and execute Salesforce test cases — including data-driven runs and parallel execution across sandboxes.
{% endhint %}

This page covers the full lifecycle of a Salesforce test case in ContextQA: recording, data management, execution, and reviewing logs.

## Interactive course: create and run your first Salesforce test

The two course segments show how a reusable Salesforce test is authored and then run. They are ungated, so you can follow the captured workflow without a ContextQA or Salesforce login.

### Part 1 — Create the test case

{% embed url="<https://app.storylane.io/share/pzi3ilyscfqz>" %}

### Part 2 — Run the Salesforce login test

{% embed url="<https://app.storylane.io/share/6ly4wltvw2d1>" %}

### What to notice

* A reusable login case can become a prerequisite instead of being copied into every Salesforce scenario.
* Captured steps retain human-readable intent and element context for review after Lightning changes.
* The run result connects each action, validation, and evidence item to the same execution.

![ContextQA Salesforce test editor showing natural-language steps, AI verification, and a reusable session-login prerequisite](https://4255556216-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKlyaXxb76z3Dn47TrZkU%2Fuploads%2Fgit-blob-64c2aeadbb67e1959cf3797031b1f8352f5656d8%2Fcontextqa-generated-salesforce-test.png?alt=media)

The existing editor screenshot above shows an opportunity case with a broad text-presence assertion. For release checks, assert the exact expected stage and persisted history; partial text presence alone is insufficient. The example illustrates authoring after reusing a dedicated Salesforce session prerequisite. This keeps authentication separate from the business assertion and makes the same logged-in setup available to multiple lead, opportunity, CPQ, and service scenarios. For lifecycle-level coverage and measurable business outcomes, see [Salesforce and enterprise workflows](https://learning.contextqa.com/walkthroughs-demos-and-examples/business-use-cases/salesforce-and-enterprise-workflows.md).

## Recording a Salesforce test session

ContextQA creates test cases by recording your interactions with the Salesforce UI. The recorder captures not just the element locator but also metadata — label, role, surrounding context — so the AI can re-locate elements even after Salesforce regenerates its DOM identifiers.

1. In ContextQA, click the **plus (+) icon** to start a new scenario.
2. Select **Start recording** (or choose an existing scenario to extend).
3. Perform the Salesforce workflow you want to automate: navigate to a record, fill in fields, click action buttons, submit forms.
4. Stop the recording when the workflow is complete.
5. Click the **Edit icon** (three dots) on any step to review the captured locator and metadata. ContextQA stores both to support review and element recovery when the UI changes.

Stored metadata can help resolve changed elements. Validate critical suites after Salesforce updates and review any locator recovery evidence. A changed field meaning, permission, or business rule still requires explicit review.

## Executing a recorded test case

1. Open the test case in ContextQA.
2. Click **Run**.
3. Wait for a terminal result. Use appropriate readiness assertions and bounded waits for asynchronous Salesforce operations; investigate timeouts rather than hiding them with arbitrary delays.
4. Review the results in the execution view. A pass confirms only the assertions executed in that run. Verify saved records, role behavior, and relevant downstream outcomes before release sign-off.

## Interactive demo: execute a Salesforce test with dynamic data

Use this walkthrough to see a saved Salesforce case execute with data resolved at runtime instead of relying on hard-coded record values.

{% embed url="<https://app.storylane.io/share/qnxn3if9doom>" %}

### What to notice

* Environment and profile values are selected independently from the Salesforce test logic.
* Dynamic values make repeated runs less likely to collide with existing sandbox records.
* The execution report preserves the resolved outcome while protected values remain outside the test description.

## Managing test data with profiles

Hardcoding values like usernames, passwords, or record field data into test steps makes tests brittle and difficult to maintain. ContextQA separates test data from test logic using **test data profiles**, **parameters**, and **variables**.

### Parameters vs. variables

| Concept   | What it is                                                  | When to use it                                                                        |
| --------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Parameter | An input value injected from a test data profile            | Usernames, passwords, record field values provided before the test runs               |
| Variable  | A value captured during execution and reused in later steps | Order IDs, confirmation numbers, or any value generated by the application at runtime |

### Creating a test data profile

A test data profile is a table of input values — each row is one data set. Use synthetic business inputs and approved protected authentication configuration. Limit access to sensitive values and exclude them from screenshots and exported reports.

Navigate to the test data profiles section in ContextQA to view existing profiles or create a new one for your Salesforce module.

### Connecting a test case to a test data profile

1. Open the Salesforce test case you want to parameterize.
2. Click **Add step** and hover over the menu icon.
3. Choose **For loop**. Select your test data profile, set the loop boundaries to **Start Loop** and **End Loop**, and click **Create**.
4. Click **Reorder** and drag all relevant test steps underneath the for-loop step so they execute within the loop.
5. Click **Update** to save the reordered test case.

### Replacing hardcoded values with parameters

1. Find a step that contains a hardcoded value you want to replace (for example, a username or password field).
2. Click the **Edit icon** on that step.
3. Remove the hardcoded value from the field.
4. Click **Parameter** and select the parameter that corresponds to the column in your test data profile (for example, `user_email` or `password`).
5. Click **Update** to save the step.

Repeat for every step that contains data you want to drive from the profile.

### Running with a test data profile

1. Click **Run** on the test case.
2. Choose **execution** from the run options.

ContextQA fetches each row from the test data profile and executes the for-loop steps once per row. The execution history shows one result per data set, making it easy to see which inputs passed and which failed.

## Parallel execution and test plans

For large Salesforce test suites, parallel execution reduces total run time and provides faster feedback.

### Setting up a test plan for parallel execution

1. Navigate to **Plans → Test Plans** in ContextQA.
2. Open the test plan that contains your Salesforce test cases.
3. Click the **Edit icon** on the test plan.
4. Go to the **Test Machine and Issue** section. Add your test suite and select a browser (for example, **Chrome**).
5. Click **Add** to save the machine configuration.
6. Open **Test Plan Settings** and set the parallel execution count — choose a value supported by your runner capacity, Salesforce org limits, and data-isolation strategy.
7. Click **Update** to save, then click **Run** to execute the test plan.

ContextQA executes cases with the configured concurrency subject to available runner capacity. Each test case manages its own wait state independently, so a test that is waiting for a Salesforce record to save does not block other tests from proceeding.

## Reading execution logs

After a test plan runs, open **Run History** to review results.

* The run history shows the pass/fail status for every test case in the plan.
* Click any test case entry to open the detailed execution log, which includes each step, its pass/fail status, and timestamps.
* For failed steps, the log shows what was expected and what actually occurred. Common causes in Salesforce tests: a field was not found because of a UI change, a record was not saved before the next step attempted to read it, or test data was invalid for the target environment.

Use the timestamps to identify slow steps that might indicate Salesforce performance issues or timing problems in a specific environment. If a test is consistently failing in a particular sandbox but passing elsewhere, compare the environment configuration and data state rather than assuming a test logic error.

{% hint style="info" %}
**AI-assisted Salesforce testing without Salesforce test expertise.** [**Book a Demo →**](https://contextqa.com/book-a-demo/?utm_source=learning_contextqa\&utm_medium=documentation\&utm_campaign=salesforce_interactive_demo\&utm_content=test_generation_execution) — See ContextQA automate Salesforce Lightning UI testing for your org.
{% endhint %}

## Generate cases from a module requirement

Choose a [cloud or industry guide](https://learning.contextqa.com/packaged-application-testing/salesforce-testing.md), supply the actual objects, roles, active rules, expected values, and rejection conditions, and generate proposed cases from that requirement. Review the steps before execution, add the appropriate login prerequisite, and parameterize run-owned data. Use [hybrid UI and API assertions](https://learning.contextqa.com/packaged-application-testing/salesforce-testing/hybrid-ui-api-testing.md) for saved outcomes and [release readiness](https://learning.contextqa.com/packaged-application-testing/salesforce-testing/seasonal-release-readiness.md) for sign-off.


---

# 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://learning.contextqa.com/packaged-application-testing/salesforce-testing/test-generation-and-execution.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.
