JavaScript Files
JavaScript Files contain JavaScript code that can be reused across checks. JavaScript Files can be used in either Real Browser checks or in API Checks. Only administrators have access to View, Create, Edit, or Delete JavaScript files, but any user can add an existing JavaScript File to a check.
Administering
To view, add, edit, or delete a JavaScript File, go to the Admin
menu at the top right of the screen and click on JavaScript Files
. When adding or editing a JavaScript File, you will be given a form with two fields:
- Name: This will be the name that you will use to reference the file when adding to a check.
- Filename: This is a file upload button, where you can choose the local file to upload.
Adding to a Check
To add a JavaScript File to a check, create a new check or edit an existing check. Go to the Advanced
configuration of the check and look for the JavaScript Files
section. You can add or delete JavaScript Files from the check.
If you need to add a JavaScript File in the middle of editing a check, make sure that you save your changes and then add the JavaScript File and edit the check again to add the JavaScript file.
Setting Up and Testing JavaScript Files
You will want to create a step within your Real Browser Check that calls upon the JavaScript file, to give an example:
Create a JavaScript file and upload.
function testJSFile() {
return 'This worked!';
}
Then create/edit a check with the new JavaScript file attached. Finally, add an "execute JS" step:
testJSFile();
Hit 'Test' and it should pass if everything is configured correctly.
More Information
Read more about using JavaScript files with Rigor Real Browser checks on our blog.