Custom JavaScript actions
Last updated
Was this helpful?
Last updated
Was this helpful?
If you know how to code in JavaScript, you can overcome any limitations of BugBug features. With the power and flexibility of custom code actions, you can run any function during your tests.
Use JS code to add complex assertions. Run any function and if it returns true
the assertions will pass.
Example: assert if an input element has a specific placeholder text.
Record a regular assertion to the input.
Change its type to "Custom Javascript assertion"
Enter custom JS code that checks the placeholder of the element, for example
if (element.placeholder === 'Username') { return true } else {return false}
Here's an example of how to make a server-side request from Javascript.
We listed several ideas on what you can achieve with API requests via code:
Compare the data displayed in your app with the data returned from the server
Check if your currency exchange is up-to-date
Get a list of test users and their parameters from a centralized testing data file
Get a login and password for your random test user, skipping the registration process
Get the latest item from a server and its ID
Check if the most recently added product is shown on the list of search results
Remember! You can also use in your custom code
Using the custom JS you can really do anything. For example, you can request some data from your API and use this data in a or in an assertion.
Learn more in the full