What is a JS Step?
How to Add a JS Step in Your Scenario
- Go to the Scenario Details Page where you want to add the JS Step
- Move the cursor in between the steps where you want to add the JS Step
Click the + icon and and select Insert Step. Select JS Step from the menu that appears.
- 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
- Select what happens if the JS Step fails.
- 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 :
- Use a return statement in your JS Step
In the Scenario Details Page, click on the step you wish to insert the return value in
In the Text to assign dropdown, select Other step's result and select the desired JS Step whose data you wish to insert
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:
Click on the thumbnail of the JS Step, which you want to pass in an argument for.
Click on the + icon within the parenthesis of the function
- Enter the name of your argument and click Add
- In the Argument Values, select the type of value you'd like to pass in
- Given value allows you to hardcode in a string
- Data allows you to select from the columns in your CSV file
- 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
JS Steps 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:
- Click on the "Autify Help Center" link
How to use JS Snippets
Add a JS Step in your Scenario (reference the "How to add a JS Step" section in Autify University for instructions)
In the Autify JS Snippet database, select the snippet you wish to use
Copy the JS snippet by hovering over it and clicking the "copy" icon on the top right corner of the snippet
- Paste the snippet into your JS Step and make the necessary changes to the code to suit your test