Scripted Tests are a crucial aspect of the Splunk Synthetic Monitoring platform.They are made up of steps, with each step performing some action or navigation on a page. Scripted Tests can be used to measure a user flow, record business transactions across a page, and more. In order to write useful scripts it is important to understand how Steps, Actions, Wait Times and Navigations work.
The Steps
Steps are comprised of a Name, Action and corresponding value or selector, Business Transaction, and settings. Each Script is made up of one or more steps and steps denote actions to be taken by the script. These actions are then recorded, executed, and completed or failed.
Each action performs a specific function in the step. For example: a ‘Click’ action will click on whatever you direct it to and a ‘Fill in Field’ action will direct the script to fill in the desired text in the field that is directed. Whichever action is selected for the the step there will be a corresponding selector, value, and value to point that step to.
In this example, this step is configured to perform a click action on a component with an id of ‘12345’. When this step runs the recorder will look for the corresponding id and will make a click action.
If multiple steps are configured for a Real Browser Check, then Splunk Synthetic Monitoring will record each step into a filmstrip that will show the progression of your steps just as you have scripted. However, your filmstrip may show a different story than you may want if you haven’t properly configured your script.
Waiting for Navigation
One key aspect for writing scripts properly is accounting for page navigation. Page navigation occurs when a step has resulted in the navigation from one page to another. This could be the result of clicking a link, executing some JavaScript code, explicitly navigating to a specific URL, or less frequently, filling in a text field, or choosing an option in a dropdown. Accounting for this page navigation is done at the step level and is as easy as checking a box.
Splunk Synthetic Monitoring has pre-configured the ‘Wait for Navigation’ box to appear for certain actions that may result in page navigation, and has checked the box for steps that will certainly result in page navigation; such as a ‘Go to URL’ step. If this checkbox is misconfigured, your script will not run properly, so it is important to carefully script each step taking page navigation into account.
When the “Wait for Navigation” checkbox is selected, Splunk Synthetic Monitoring will wait a short duration after each of these steps to see if navigation occurs. If this is selected for steps that are known to not cause navigation, your check will experience a short delay between that step and the next, unnecessarily. But by unselecting the “Wait for Navigation” checkbox, Splunk Synthetic Monitoring will not wait to detect page navigations, resulting in no delays between steps in your check.
It is important to note that if you expect a step to cause navigation, then this setting must be enabled. Otherwise Splunk Synthetic Monitoring cannot detect that navigation has occurred and the check will likely fail.