You are here:
How to Write End-to-End Tests with UTAM for Flexcards
To fully automate and stabilize your guided user flows, structure and build end-to-end tests for Flexcards by using UTAM's commands.
Sample UTAM Methods for Flexcards
These methods are critical parts of the Omniscript Page Objects (POs). Use them to replicate essential user actions.
| Method | Component | Purpose | Example Action |
|---|---|---|---|
waitForVisible() |
General PO | Ensures the UI component has finished loading and is ready for interaction. | Waits for the spinner to disappear. |
getFlexCardStates() |
Flexcard | Retrieves a list of the states in the flexcard. | Finds the first state in the flexcard. |
getElements() |
FlexCardState | Retrieves the list of all elements in a flexcard state. | Finds the number of elements in a flexcard state. |
isValid() / getErrorMessage() |
Input POs | Checks if the element currently passes validation rules. | Confirms a required field shows: Error: Field is
required. |
Write End-to-End Tests for Flexcards with UTAM
Use these steps to structure your UTAM test class, set up your environment, and run the main logic required for an end-to-end Flexcard validation. This example uses Maven.
-
- Configure the initial setup. See UTAM, Java, and JavaScript.
- Setup and navigation: Before writing your test logic, make sure that your
environment is set up and your test class is configured.
-
Helper methods: It's highly recommended to abstract login, navigation, and environment configuration into reusable helper methods defined in a base test class (example,
SalesforceWebTestBase). This keeps your test logic clean and maintainable. -
Test setup: Use the
@BeforeTestannotation to define the setup logic, including browser initialization and logging into the target Salesforce org.// Handles browser setup and login before tests run @BeforeTest public void setup() { setupChrome(); login(testEnvironment, "home"); }
-
- Test logic: The actual test method uses the
@Testannotation (example, for Maven) and orchestrates the user interaction sequence.- Load and wait for visibility: After retrieving the Flexcard PO, always wait
until it is visible before interacting with elements. This makes sure that the UI
and underlying LWC components are rendered.
Example:
FlexCard flexcard = goDirectlyToFlexcard(); flexcard.waitForVisible(); - Retrieve card state and elements: Each Flexcard contains one or more
FlexcardStateobjects. Access the required state and retrieve its list of elements:Example:
FlexCardState state = flexcard.getFlexCardStates().get(0); List<Element> elements = state.getElements(); - Testing element validation:
- To read labels or values displayed by the Flexcard, access the nested
OutputFieldPO:Example:
String label = elements.get(0) .getOutputField()..getLabel().getText(); - Assert that the label matches the expected value:.
Example:
Assert.assertEquals(label, "Result", "The label is not correct");
- To read labels or values displayed by the Flexcard, access the nested
- Load and wait for visibility: After retrieving the Flexcard PO, always wait
until it is visible before interacting with elements. This makes sure that the UI
and underlying LWC components are rendered.
- Sample Flexcard Test (Java)
This example demonstrates the complete end-to-end user journey, including setup, navigation, and interaction with Flexcards.

