- Prepare your environment
- Create the script
- Test the script
- Declare variables
- Use variables in the script
- Specify milestones
- Save the workflow
- Run the script on a monitoring point
Use the AppNeta Synthetic scripting language to create scripts used for Experience monitoring. Before you can create a script you need to create a web app group containing the web application you want to test and the monitoring points you want to test it from. You can then edit the Workflow associated with the web app group to create the script. Creating the script involves entering the scripting commands then using the Preview feature to test it. Once you are happy with the script and complete the script creation process, the script runs automatically on the monitoring points associated with the web app group.
Prepare your environment
There are several points you should consider before you start scripting:
- Use Chrome for testing - Since the monitoring point uses Chrome to execute the script, it is best to use Chrome when creating the script.
- Script against the target URL - During script creation, make sure that you script against the same version of the site that the monitoring point will access when it runs the script.
- Script against an accessible target - Remember that the script you create will be run on a monitoring point and it needs to be able to access the target.
- Obtain the login credentials - We recommend that you set up a dedicated account for the script to log into the application being tested. Give it the minimal permissions required for your script to run.
- Use a clean browser - Remember that each time it runs, your script will be starting from a blank slate, so you’ll need to make sure the browser you are creating the script with is equally clean:
- Close all unnecessary tabs.
- Clear out your browser’s cache and cookies.
- Disable any plug-ins you don’t need or that could interfere with the script, particularly script blockers and ones that automatically enter text into fields, such as password managers.
The following additional points are recommended, but not compulsory:
- Plan ahead - As with any coding endeavor, it’s best to plan out what you’re trying to do ahead of time. Spend some time thinking about what you want to test, and what results you expect to see from it.
- Use two different browsers on two different monitors - Have the site you’re testing against open in Chrome on one monitor, and APM open in a different browser on another monitor. This ensures you don’t lose your work if the site you are testing against hangs or crashes Chrome. Also, you can restart Chrome and clear your cookies without affecting your APM session. While troubleshooting, perform an action on the Chrome monitor and observe the result. Then edit your code accordingly in APM on the other browser and monitor.
- IP address logging/alerting - If you log authentication requests, consider excluding alerts on attempts to authenticate from your testing workstation’s IP address and the public IP addresses of the monitoring points running the script. Not doing so can fill the log with unnecessary entries.
Create the script
This step assumes that you have already created a web app group.
To create an AppNeta Synthetic script:
- Navigate to Experience > Web App Groups.
- Click Configure for the web app group you want to create a script for.
- In the Workflows… pane, click the edit icon next to the workflow you want to edit.
- The Edit Workflow page opens.
- In the Script section, select AppNeta Synthetic Script.
- The AppNeta Synthetic scripting commands and their descriptions are listed above the script editor.
- Select the command you want to enter and click + Add to add the command to the editor.
- You can also type commands directly into the editor.
Test the script
Once the script is created, you need to test it on a monitoring point.
To test the script:
- In the Preview section of the Edit Workflow page, select a monitoring point and a target.
- The monitoring point should be one of those in the Monitor from… section of the web app group. The target should be one of those in the Monitor to… section of the web app group.
- Click Preview.
- The script is sent to the monitoring point and queued for execution.
- As the script executes, APM captures a screenshot approximately every second.
- Confirm that the screen shots are what is expected and that the script completes properly with no errors.
If the script captured user credentials that have a password you do not want visible, you can declare a password variable to mask its value. Those variables declared as “password”, “passwd”, “pwd”, or “secret” have their values masked. All other variable names do not have masked values.
To declare a variable:
- In the Variables section of the Edit Workflow page, specify the variable name and value.
Use variables in the script
Once variables have been declared, they can be used in the script. For example, let’s assume a variable called “password” was created above.
To add a “password” variable to the script:
- In the Script section of the Edit Workflow page (with AppNeta Synthetic Script selected), declare the “password”.
declare $passwordto the top of the script.
- Within the script, replace the actual password with
A milestone is a collection of one or more commands that represent a unit of work that you want to measure. For example, accessing a web app, logging in to the web app, and performing various actions within the web app. Assigning a milestone to each of these actions allows you to narrow down where a slowdown is occurring. Without timing data for each milestone, all you know is that the web app is slow.
A script can have up to 20 milestones.
To specify a milestone in a script:
- In the Script section of the Edit Workflow page (with AppNeta Synthetic Script selected), add the milestone.
- This can be done in a couple ways:
'<milestone-name>'to the end of
waitcommands. For example,
clickAndWait id='login-button' 'Milestone 2: Login'.
- This can be done in a couple ways:
Save the workflow
If you have added variables or milestones you should use the Preview to retest and confirm there are no errors. Once this is done you can complete the process.
To complete the process, save the workflow:
- Click OK
- Click Save
Run the script on a monitoring point
Once the script is saved in APM, it is automatically downloaded to the monitoring point(s) associated with the web app group and is queued for execution. It takes some time (based on the test interval configured) to see test results.
To see the web path status:
- Navigate to Experience > Web App Groups.
- Select the web app group containing the script you created.
- The status is in the left column of the individual web paths in the web app group.
- You can also click the web path for detailed test results.
For the script to continue to run without problems, the target environment must be stable. Some things to consider are:
- Password expiry—Some web applications require new passwords periodically. Set a reminder to change passwords used in your scripts before they expire.
- Web application changes—Changes to a web apps can cause your script to fail. Be sure to check that the script continues to run successfully when your web app changes.
- Staging environment—Test against your staging environment as well as your production environment. This allows you to catch changes that affect script execution as well as to benchmark changes in application performance before it is run in production.
The following examples can be used within APM.
To use the examples below:
- Click the Script link in the example you want to use.
- Copy the script source.
- Follow the steps above from Create the script but paste the copied script into the script editor rather than entering the commands manually. Use the other information included in the example as appropriate in the steps that follow.
Login to APM example
Target URL: https://login.appneta.com
Variables: username, password
Script: APM login example
Target URL: https://en.wikipedia.org
Script: Wikipedia example