Add synthetic transactions to your browser test
Customize your browser tests by adding a synthetic transaction that monitors a multi-step user flow, such as. a checkout flow that requires various interactions on a webpage.
Use synthetic transactions in your browser tests to test multi-step user flows and transactions.
What are synthetic transactions?
A synthetic transaction is a group of one or more logically related interactions (steps) that represent a business-critical user flow, such as the login process or a checkout flow.
Splunk Synthetic Monitoring generates the following additional metrics for each synthetic transaction:
Duration: Total duration for the synthetic transaction
Requests: Total number of requests made during the synthetic transaction
Size: Total size of the content loaded during the synthetic transaction
You can create multiple synthetic transactions in a given test to measure size, duration, and requests for multiple workflows across multiple pages.
What are steps?
Steps are interactions with a webpage that require user input. By adding steps to your browser test, you can simulate choices or interactions that a user makes and test how your application behaves in response. Sample steps include:
Clicking a link
Entering information in a field
Selecting a value from a drop-down menu
Accepting or dismissing an alert
Running and saving values from JavaScript
Saving text from an element
You can identify specific page elements involved in these steps by their ID, name, XPATH, CSS Path, link, or JS path. Use developer tools to interact with the DOM (inspector) and JavaScript (console) to identify and interact with the elements of a site.
To learn more about all available types of steps, see Types of steps you can include in your browser tests.
A step doesn’t generate its own dedicated metrics, but it counts toward the metrics for the synthetic transaction it belongs to. Additionally, when a step triggers a new page load, the page load triggers a set of page load metrics.
What are assertions?
Assertions are checks to see what state an object exists in, for example if text is present or an element is visible. An assertion is a type of step. The assertions you can include in your browser tests are described in Types of steps you can include in your browser tests.
You can make an assertion on two values. Add two parameters along with the comparison that you would like to perform between the two. There are three types of comparisons: string, numeric, and regular expression. For string and numeric comparisons, values are coerced to the comparison type before the comparison is made. For a regular expression comparison, the first parameter is a string and the second parameter is a regular expression. An assertion step fails if the assertion is false when the step runs.
Use matches to compare the string to a regex pattern.
Use contains checks for a substring.
Types of steps you can include in your browser tests
- Accept alert
- Accept an alert that appears on the page.
- Assert element present
- Check if the element exists in the DOM even if it's hidden. Use this assertion when you just need to confirm that the element loaded (for example, when it's in a hidden modal or tab).
- Assert element visible
Check that the element exists and is actually visible to the user (in other words,
display != none,opacity > 0, and so on). Use this assertion when you want to make sure the element is onscreen and interactable.Example: If an element is hidden behind a
display: nonestyle, the "Assert element present" step will pass but the "Assert element visible" step will fail.- Assert text present
- Check if text exists in the DOM, even if it's hidden. Use this assertion when you need to confirm that the text loaded (for example, in a hidden modal or tab).
- Clear (with optional wait for navigation)
Clear an element you identify under Selector. Optionally, add a Wait for navigation.
- Click (with optional wait for navigation)
Click on an element you identify under Selector. Optionally, add a Wait for navigation.
- Dismiss alert
- Dismiss an alert that appears on the page.
- Execute JavaScript (with optional wait for navigation)
Execute a piece of JavaScript you provide under Value. Optionally, add a Wait for navigation.
- Fill in field (with optional wait for navigation)
Fill in the field you identify under Selector with a value you provide in the Value field. For security and reusability, you may want to use a built-in, custom, or global variable in the Value field. Reference a custom variable as
{{custom.your-variable-name}}. Optionally, add a Wait for navigation.- Go to URL
Navigate to a URL you provide in the URL field.
- Save return value from Javascript (with optional wait for navigation)
Execute a piece of JavaScript you specify in the JavaScript field. If the script returns a value you want to save, specify a name for the saved value in the Variable field. This creates a custom variable which you can reference in subsequent steps as
{{custom.your-variable-name}}. Optionally, add a Wait for navigation.- Save text from element
Save the text an element you identify under Selector, as the variable you provide under Variable.
- Select (with optional wait for navigation)
Select an element you identify under Selector. Choose the value you identify under Value. Optionally, add a Wait for navigation.
- Switch to iframe
Switch focus to an embedded document in an inline frame, identified under Selector.
- Switch to main
- Switch focus back to the main frame of the webpage.
- Wait
Wait a specified number of milliseconds. This custom wait time is in addition to the default 10s wait time between steps.
Tip:In addition to this explicit Wait step, there are also wait options embedded into other steps:
- On Assert element present and Assert element visible steps you there's an option to Wait up to X ms (useful for waiting for a loading spinner to disappear).
- On steps that can trigger a new page load (Click, Execute JavaScript, Fill in field, and so on) there's an option to Wait for navigation (useful for waiting for an order confirmation page after clicking a checkout button).
The following table lists the limits for each type of wait time. The maximum limit for a single run is 30 minutes (1,800,000 ms), after which it times out.
Description
Limit
Wait step The total sum of all explicit "wait" steps for each test is 200,000 ms (200s). Wait option within an assertion step (Wait for up to)
90 seconds
Wait for navigation
20 seconds
Add synthetic transactions to your browser test
Follow these steps to create a browser test with synthetic transactions:
From the Splunk Synthetic Monitoring landing page, click Add new test > Browser test to create a new browser test.
While creating your browser test, select Edit steps or synthetic transactions. Your current configuration and detector selections are preserved and the Add synthetic transactions view opens.
Enter a name for your synthetic transaction, such as Log in or Begin search.
Enter a name for the first step in your synthetic transaction.
Select a step type from the pull-down menu.
If your step type requires you to identify an element by Selector, enter the following.
Selector type: Specify the selector type (ID, name, XPATH, CSS Path, link, or JS path).
Selector path: Specify the path used to identify the selector you’re using, conforming to the selector type you chose.
If your step type requires that you enter a Value, you can either type a raw value, or use a built-in, custom, or global variable here. You can select a variable name from the Variables tab to copy it and paste it in the field where you’d like it to be entered.
If your step type has the option to Wait for navigation, select the checkbox if you’d like the test to wait for a 2 second delay to allow the specified action to be executed.
(Optional) Create additional steps and synthetic transactions using the + Step and + Synthetic transaction buttons. Click and drag steps and synthetic transactions to rearrange their order.
(Optional) Use the Test settings tab to adjust your test configuration settings. See Advanced test configurations to learn more.
(Optional) Use the Detectors tab to add detectors to your test. See Detectors and alerts to learn more.
When you’re satisfied with your transactional browser test, select Save.
Import a JSON file generated from Google Chrome Recorder
To simplify the test creation process, make a recording using Google Chrome Recorder. Then, import the JSON file to Splunk Synthetic Monitoring to automatically import the steps in the workflow instead of adding each individual interaction you want to track. Recordings are especially helpful for complex user flows, or tests that have a large number of steps.
Create a Google Chrome Recorder JSON file
For steps on how to make a Google Chrome recording, see Record, replay, and measure user flows in the Chrome Developer user guide in Google documentation.
Requirements:
In Google Chrome Recorder, select either CSS or XPATH for Selector type to record.
Browser tests run in one Browser tab only. Your recording can’t span multiple tabs.
Import a Google Chrome Recorder JSON file
Follow these steps to import a JSON file from Google Chrome Recorder to a new or existing browser test.
In Splunk Synthetic Monitoring, select Edit on an existing browser test to open the test configuration page, or create a new test.
Select Import.
Upload the Google Chrome Recorder JSON file.
If a step is not supported, edit or delete that step in the test configuration page.
(Optional) Add a name to each step.
Save your changes.
Troubleshoot unsupported steps
If your recording contains unsupported steps, you need to edit the step to reformat it into one of the supported browser step types. The following table shows how Google Chrome Recorder step names and code snippets map to their counterparts in browser tests. These examples use Buttercup Games, a fictitious gaming company.
- navigate
{ // Google Chrome Recorder "type": "navigate", "url": "www.buttercupgames.com", "assertedEvents": [ { "type": "navigation", "url": "www.buttercupgames.com", "title": "Buttercup Games" } ] }- go_to_url
{ // Splunk Synthetic Monitoring code snippet "name": "Go to URL", "type": "go_to_url", "url": "www.buttercupgames.com", "wait_for_nav": true }
- clickwith resulting navigation
{ // Google Chrome Recorder "type": "click", "target": "main", "selectors": [ [ "div:nth-of-type(2) > div:nth-of-type(2) a > div" ], [ "xpath//html/body/main/div/div/div[2]/div[2]/div/a/div" ] ], "offsetY": 211, "offsetX": 164, "assertedEvents": [ { "type": "navigation", "url": "www.buttercupgames.com/product/example", "title": "Buttercup Games" } ] }- click_elementwith resulting navigation:
{ // Splunk Synthetic Monitoring code snippet "name": "", "type": "click_element", "selector_type": "css", "selector": "div:nth-of-type(2) > div:nth-of-type(2) a > div", "wait_for_nav": true }
- clickwithout resulting navigation:
{ // Google Chrome Recorder "type": "click", "target": "main", "selectors": [ [ "div:nth-of-type(2) > div:nth-of-type(2) a > div" ], [ "xpath//html/body/main/div/div/div[2]/div[2]/div/a/div" ] ], "offsetY": 211, "offsetX": 164, "assertedEvents": [] }- click_elementwithout resulting navigation:
{ // Splunk Synthetic Monitoring code snippet "name": "", "type": "click_element", "selector_type": "css", "selector": "div:nth-of-type(2) > div:nth-of-type(2) a > div", "wait_for_nav": false }
- change:
{ // Google Chrome Recorder "type": "change", "value": "5", "selectors": [ [ "#quantity" ], [ "xpath///*[@id=\"quantity\"]" ] ], "target": "main" }- enter_value:
{ // Splunk Synthetic Monitoring code snippet "name": "", "type": "enter_value", "selector_type": "id", "selector": "quantity", "option_selector_type": "index", "option_selector": "5", "wait_for_nav": false }
- waitForElement:
{ // Google Chrome Recorder "type": "waitForElement", "selectors": [ [ "body", "#homepage_example", ".css-4t2fjl", ".eanm77i0" ] ] }- assert_element_present:
{ // Splunk Synthetic Monitoring code snippet "name": "", "type": "assert_element_present", "wait_for_nav": false, "selector_type": "css", "selector": "body,#homepage_example, .css-4t2fjl, .eanm77i0" }
- waitForElementvisible false:
{ // Google Chrome Recorder "type": "waitForElement", "selectors": [ [ "body", "#homepage_product_brand-example", ".css-4t2fjl", ".eanm77i0" ] ], "visible": false }- assert_element_not_present:
{ // Splunk Synthetic Monitoring code snippet "name": "", "type": "assert_element_not_present", "wait_for_nav": false, "selector_type": "css", "selector": "body,#homepage_product_brand-example" }
- customStep:
{ // Google Chrome Recorder "type": "customStep", "timeout": 5000, "target": "main", "name": "customParam", "parameters": {} }- run_javascript:
{ // Splunk Synthetic Monitoring code snippet "name": "Unsupported step customStep", "type": "run_javascript", "value": "", "wait_for_nav": false }