Loading
Feature Degradation | Agentforce Voice Read More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          How to Write End-to-End Tests with UTAM for Flexcards

          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.

          Note
          Note Before you start writing end-to-end tests for Flexcards using UTAM, make sure you have a good understanding of UTAM.
            1. Configure the initial setup. See UTAM, Java, and JavaScript.
            2. 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 @BeforeTest annotation 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");
                }
                
            3. Test logic: The actual test method uses the @Test annotation (example, for Maven) and orchestrates the user interaction sequence.
              1. 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();
                
              2. Retrieve card state and elements: Each Flexcard contains one or more FlexcardState objects. Access the required state and retrieve its list of elements:

                Example:

                FlexCardState state = flexcard.getFlexCardStates().get(0);
                List<Element> elements = state.getElements();
                
              3. Testing element validation:
                1. To read labels or values displayed by the Flexcard, access the nested OutputField PO:

                  Example:

                  String label = elements.get(0) .getOutputField()..getLabel().getText();
                2. Assert that the label matches the expected value:.

                  Example:

                  Assert.assertEquals(label, "Result", "The label is not correct");
          • Sample Flexcard Test (Java)
            This example demonstrates the complete end-to-end user journey, including setup, navigation, and interaction with Flexcards.
           
          Loading
          Salesforce Help | Article