※ Please note that parts of this page are machine translated.
What is a JS Step?
This function opens up various functions that are not possible with Autify’s standard functions.
This is a powerful feature so we have provided a detailed explanation below.
After the section on how to use this function, there are specific use cases in the latter part of this article. We hope they are useful!
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
Use a value obtained or generated in a JS Step in other steps
In [JS Step], you can obtain information from elements displayed on the page or generate values.
return allows you to use this information in subsequent steps. The actual
return value can be seen on the test result.
If you have not
return in JS step, this value will be
Only strings and numbers can be used in subsequent steps.
Used in the operation and assertion 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
Use as Arguments of a JS Step
Values returned by a JS step can be used as arguments for other JS steps. Details are explained in the section "Using Arguments in JS Step" below.
Using Arguments in a JS Step
- 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
To delete or rename an argument that has already been added, click on the target argument and make the necessary edits
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.
Add a JS step to the scenario
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
JS Steps Use Cases
- API calls
- Handling cookies
- Custom assertions