You are here:
How to Write End-to-End Tests with UTAM for Omniscripts
To fully automate and stabilize your guided user flows, structure and build end-to-end tests for Omniscripts by using UTAM's commands.
Sample UTAM Methods for Omniscripts
These methods are critical parts of the Omniscript Page Objects (POs). Use them to replicate essential user actions, from loading the component to navigating between steps and invoking actions in your automated tests.
| Method | Component | Purpose | Example Action |
|---|---|---|---|
waitForVisible() |
General PO | Ensures the UI component finished loading and is ready for interaction. | Waits for the spinner to disappear. |
getSteps() |
Omniscript | Retrieves a list of the flow's steps so you can target a specific one (example, index 0). | Finds the first step in the flow. |
getElementWithName() |
OmniscriptStep | Retrieves a specific element PO (example, a text input) using the element's Name (API Name). | Targets the Username input field. |
getElements |
OmniscriptStep | Retrieves a list of all elements of a particular type from a given omniscript step. | Targets all text elements in a step. |
setValue(value) |
Input POs | Simulates a user typing input into a field. | username.setValue("testdata"); |
getNextButton().click() |
Omniscript | Simulates the user clicking the navigation button. | Moves the flow from Step 1 to Step 2. |
isValid() / getErrorMessage() |
Input POs | Checks if the element currently passes validation rules. | Indicates that a field is required: Error: Field is
required. |
invokeAction() |
Action POs | Triggers actions linked to the component, such as Remote Actions. | Executes a button-linked server-side process. |
Write End-to-End Tests for Omniscripts 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 Omniscript 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"); }- Omniscript navigation: Use a helper method (example, goDirectlyToOmniscript) to navigate to the Omniscript's specific App URL, returning the main Omniscript Page Object (PO).
-
- Test logic: The actual test method uses the
@Testannotation (example, for Maven) and orchestrates the user interaction sequence.- Load and navigate to the first step: Make sure that the test successfully
retrieves the Omniscript PO and waits until the UI is ready.
- Retrieve PO: Call your helper method to launch the Omniscript and assign it
to the main Omniscript PO.
Example:
Omniscript omniscript = goDirectlyToOmniscript("OmniScript", "Test", "English", "lightning"); - Wait for load: Use the
omniscript.load()andomniscript.waitForVisible()methods to wait for the UI spinner to disappear and the component to be ready for interaction. - Get step PO: Retrieve the PO for the first step in the flow. The
getSteps()method returns a list of steps, where the first step is at index 0.Example:
OmniscriptStep step1 = omniscript.getSteps().get(0); - Wait for step: Make sure that the step is fully visible before attempting to
interact with elements.
Example:
step1.waitForVisible();
- Retrieve PO: Call your helper method to launch the Omniscript and assign it
to the main Omniscript PO.
- Interact with elements and assert input: To interact with an element, you must
retrieve its specific PO using its Element name (not the Label).
- Get element PO: Retrieve the PO for an element inside the step using
getElementWithName(), passing the element's name and its specific PO
class.
Example:
OmniscriptText username = step1.getElementWithName("Username", OmniscriptText.class); - Set Value: Input the test data using the setValue() method.
Example:
username.setValue("omnistudio"); - Assert Input: Verify that the element correctly holds the value you set.
Example:
Assert.assertEquals(username.getValue(), "omnistudio", "The value of Username is not correct");
- Get element PO: Retrieve the PO for an element inside the step using
getElementWithName(), passing the element's name and its specific PO
class.
- Advance flow and test actions for Omniscripts: Test the primary actions of the
guided flow, such as navigation and Remote Actions.
- Navigate next: Click the Next button to advance the flow or trigger
validation checks.
Example:
omniscript.getNextButton().click(); - Test Remote Action: Retrieve the PO for an action element and use the
invokeAction()method to test the functionality.Example:
OmniscriptRemoteAction submit = step2.getElementWithName("Submit", OmniscriptRemoteAction.class); submit.invokeAction();
- Navigate next: Click the Next button to advance the flow or trigger
validation checks.
- Load and navigate to the first step: Make sure that the test successfully
retrieves the Omniscript PO and waits until the UI is ready.
- Testing element validation: Testing validation logic is critical for ensuring data
quality within the Omniscript. This step also ensures that required fields show an
error when empty and allow navigation only when valid.
- Leave the required field empty.
- Click the Next button or trigger the validation.
- Assert that the element is not valid using
assertFalse("Should show error after navigation attempt", element.isValid()); - Assert that the expected error message is displayed using
assertEquals(expectedMessage, element.getErrorMessage()); - Fill the element and assert that the element is now valid using
assertTrue("Should be valid after setting value", element.isValid());
- Sample Omniscript Test (Java)
This example demonstrates the complete end-to-end user journey, including setup, navigation, interaction, and assertion across two steps.
