JS Steps
  • 22 Jul 2022
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

JS Steps

  • Dark
    Light

We like to say that we are a no-code solution. However, that does not mean that you can’t code! You can cover a broad spectrum of testing natively within Autify, but some of our clients have more advanced testing needs and want to go beyond Autify’s native capabilities; In those instances, clients can utilize JavaScript to greatly expand the scope of their testing.

What is a JS Step?

A JS step allows you to write JavaScript code in your Test Scenario to test for a variety of cases. This is a powerful feature which offers virtually limitless testing capabilities.

How to Add a JS Step in Your Scenario

  1. Go to the Scenario Details Page where you want to add the JS Step
  2. Move the cursor in between the steps where you want to add the JS Step

inset-js-step.png

  1. Click the + icon and and select Insert Step. Select JS Step from the menu that appears.
    Screen Shot 2022-07-21 at 18.22.07.png

  2. Type your JavaScript code in the text editor. The code will already be wrapped in a function, so no need to include that syntax.

Screen Shot 2022-06-13 at 5.56.28 PM.png

  1. You can optionally name your JS Step, as well as include a Memo, such as a description of what is occurring on this particular step

Screen Shot 2022-06-13 at 6.07.15 PM.png

  1. Select what happens if the JS Step fails.

Screen Shot 2022-06-13 at 6.10.40 PM.png

  1. Click Save

Using the Return Value of Your JS Snippet in Other Steps

In a JS Step, you can capture data and input it directly into subsequent steps. It is important to note that only strings and numbers can be used in subsequent steps and you cannot use the captured data in steps that occur before the execution of your JS Step.

To input data from previously executed JS Steps :

  1. Use a return statement in your JS Step

js-return-staement.png

  1. In the Scenario Details Page, click on the step you wish to insert the return value in

  2. In the Text to assign dropdown, select Other step's result and select the desired JS Step whose data you wish to insert

js-step-text-to-asign.png

This functionality is supported for the following types of step:

  • Operation step
  • Input step
  • URL transition step
  • Assertion step
  • Assertion for the page title
  • Assertion for the page URL
  • All text on the page

Using Arguments in your JS Step

You can pass the value returned from Data and other JS Steps as arguments in your JS Step. To do so:

  1. Click on the thumbnail of the JS Step, which you want to pass in an argument for.

  2. Click on the + icon within the parenthesis of the function

js-step-adding-arguments.png

  1. Enter the name of your argument and click Add

js-step-arg-name.png

  1. In the Argument Values, select the type of value you'd like to pass in

argument-values.png

  • Given value allows you to hardcode in a string
  • Data allows you to select from the columns in your CSV file

data-arg-value.png

  • Other step's result allows you to pass in the return value of a previous JS Step

To delete or rename an argument that has already been added, click on the target argument and make the necessary edits

rename-arg.png

JS Steps Use Cases

There are many different ways you can use JavaScript to test with Autify. Here are some example use cases:

  • API calls
  • Handling cookies
  • Custom assertions

JS Code Snippets

For your convenience, we have compiled dozens of the most commonly used JS code snippets when testing with Autify; You can find a link to our JS Snippets here.

You can also access the JS Snippets directly through the Autify Dashboard by:

  1. Click on the "Autify Help Center" link

Screen Shot 2022-06-21 at 5.30.44 PM.png

  1. Click "Autify JavaScript Snippets" in the Autify for Web Help Center

Screen Shot 2022-06-21 at 5.33.24 PM.png

How to use JS Snippets

  1. Add a JS Step in your Scenario (reference the "How to add a JS Step" section in Autify University for instructions)

  2. In the Autify JS Snippet database, select the snippet you wish to use
    Screen Shot 2022-06-21 at 5.39.07 PM.png

  3. Copy the JS snippet by hovering over it and clicking the "copy" icon on the top right corner of the snippet

Screen Shot 2022-06-21 at 5.40.44 PM.png

  1. Paste the snippet into your JS Step and make the necessary changes to the code to suit your test

Screen Shot 2022-06-21 at 5.44.10 PM.png


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.