Reusable JS Steps (JavaScript Snippets)
  • 28 Dec 2022
  • 1 Minute to read
  • Contributors
  • Dark

Reusable JS Steps (JavaScript Snippets)

  • Dark

Article summary

If there are JavaScript code snippets which you find yourself using often, You can save those custom snippets in Autify and insert them into any Scenario.

Creating JS Snippets in your Workspace

In your Workspace Settings, you will find a section labeled JavaScript Snippets. Here will be where all of your saved JS snippets live. To create a new snippet, click the Add button.


This will bring you to the JavaScript Snippets editor. You will first need to give a name for the Snippet you create.


From here, you can type the code that you would like to save for future use. The code is already wrapped in a function, so it is not necessary to define the function in the editor, but you may define additional functions as needed.


You also have the ability to add arguments to your function by clicking on the + button within the parenthesis. You can then input the argument values on the right-hand side of your screen. Arguments make your code snippets much more dynamic and flexible. You can find more information on arguments in the JS Steps section of Autify University.


Renaming and deleting arguments once saved is not allowed as it may break existing scenarios.
If you want to rename or delete arguments, you must create a new JavaScript Snippet.


Once done, click the Add button on the bottom of the screen.


Inserting a JS Snippet into a Test Scenario

Once your snippet is saved, you can add it to any Scenario when in the Scenario Details page. To do so, click the + button between steps at the point you want to insert the snippet. Then select Insert JS Step From Snippets. And finally, select the snippet which you want to insert.


If your JS snippet is interacting with a specific element(s), it is important to note that you will want to add the snippet at the point where that element(s) is accessible on the webpage.

After selecting your snippet, the JS step will be successfully inserted into your Test Scenario. Just as with any other JS step, you have the ability to use the return value in subsequent steps.

Screen Shot 2022-05-13 at 4.35.03 PM.png

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.