Configure custom actions using Javascript
Empower your test automation with Custom JavaScript Actions
Sometimes specific test scenarios require automation approaches beyond standard recording capabilities. These limitations present obstacles to comprehensively covering critical application behaviors.
With Custom JavaScript Actions, you can test advanced use cases by executing tailored JavaScript functions within your tests. This enables robust automation coverage even for unsupported or unique scenarios.
How to add custom actions
You can find the new custom actions step in the more menu. Click the ︙ icon from the recorder panel and select the Custom actions (JavaScript) option.
The following 3 options are provided when adding a custom action:
- Custom action
- Create variable
- Custom validation
Custom action
This option lets you perform any action by executing a JavaScript snippet on the webpage. This is similar to executing JavaScript in the console tab. For example, window.location.reload()
.
Create variable
Use this option to generate a string value using JavaScript. Return a string value, which will be stored in a variable with a name you provide. You can import the variable into any of the following steps.
Custom validation
Use this option to implement validations that require complex logic, where the recorder’s validation features are not sufficient. The function should return a true or false value. True means the validation passed and false means the validation failed.
You can click the Execute Script button to execute the step and see the results.
Variable support
You can import variables of any kind (test, data set, or module) into the step.The imported variables can be accessed within the function using the below syntax:
- variables.test[‘variable name’] - For any variable from the test scope
- variables.data[‘variable name’] - For any variable from test datasets
- variables.module[‘variable name’] - For any variable from modules imported in the test.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!