Scenarios - Simulating User Journeys
What is a scenario?
A scenario is a sequence of actions (clicks, text inputs, etc.) recorded and automated to simulate a user journey on your site.
Scenarios are essential to:
- Test tracking events. Verify that an
addToCartevent fires correctly with the right data at the moment of the click on the "Add to cart" button. - Reach pages not accessible by a simple crawl. Order confirmation pages, customer area pages or intermediate steps of a form are often not accessible via direct links. A scenario can reach them to analyze them.
- Define Crawl Modes. A scenario can be used as a "preparatory scenario" to put the browser in a specific state before the start of the crawl. For example, a scenario that logs into a customer account is the basis of the "identified visitor" crawl mode.
Creating and configuring a scenario
You can create a scenario in two ways: manually in the interface, or more quickly by recording it with the browser extension.
Manual creation:
- Go to Site > Scenarios and click on Add a scenario.
- Break down your journey into logical steps (e.g. "Page opening", "Form filling", "Validation").
- For each step, add one or more actions.
The different types of actions:
- URL opening: Starts the scenario by loading a specific page.
- Click: Simulates a click on an element identified by its CSS selector.
- Text input: Fills a form field. You can use fixed text, random text or even encrypt sensitive data like a password.
- Scroll: Scrolls the page to a specific element or coordinates.
- Frame switch: Allows interacting with elements located inside an
iframe. - Javascript: Executes custom JavaScript code, offering maximum flexibility for conditional or complex actions.
- Cursor movement: Simulates hovering over an element with the mouse.
- Drag and drop: Simulates a drag-and-drop.
- ... and other specific actions (keypress, virtual keyboard).
Crucial tip: Pauses
Between two actions, it is often necessary to add a pause to allow the page time to react and load new elements. A failed scenario is often due to poorly configured pauses.
- Wait for a delay: Fixed pause in milliseconds.
- Wait for element appearance: The best option. The scenario waits for a specific element (defined by its CSS selector) to become visible before continuing.
- Wait for resource appearance: Waits for a specific tag or script to be loaded.
Including a scenario in another: To avoid constantly recreating the same steps (like login), you can include an existing scenario (e.g. "Login") at the beginning of another scenario (e.g. "View my orders").
Scenario test: Always use the Verify button to launch the scenario in a window and ensure that all steps execute correctly before saving it.