Reusable JS Steps (JavaScript Snippets)
  • 13 Jul 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Reusable JS Steps (JavaScript Snippets)

  • Dark
    Light

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.

add-new-snippet.png

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

js-snippet-editor.png

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.

js-snippets-editor-code-block.png

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 JavaScript Steps section of Autify University.

js-snippet-code-editor-args.png

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

js-snippet-editor-add.png

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.

insert-js-snippet.png

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


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.