How to create AI-based reusable rules using testRigor?
|
|
Reusable rules (subroutines) are an integral part of test case creation. They help you write modular scripts that are compact and reusable. With testRigor, you can write reusable rules using plain English language. But that’s not the best part. You can leverage testRigor’s AI features to make the process of writing and maintaining reusable rules even more easy.
What are Reusable Rules?
A reusable rule is a step or sequence of steps that can be called into a test case by a name or description given by the user. Reusable rules are designed to exponentially increase productivity in test case creation and preemptively decrease overhead maintenance. They work wonders when trying to involve non-technical, non-testing, or high-level team members (e.g., product managers) in testing.
Here’s a guide on how to create testRigor’s Reusable Rules yourself in plain English – How to use reusable rules or subroutines in testRigor?
In this guide, we will learn how to generate reusable rules automatically through testRigor’s AI.
Pre-requisites to writing the test case
First and foremost, you need to create a test suite. Depending on the type of app you are testing, testRigor will ask you for details during test suite creation. Here are the general fields that will be visible to you during this process.
Step 1: Log in to your testRigor app with your credentials.
- Test Suite Name: Provide a relevant and self-explanatory name.
- Type of testing: Select from the following options: Desktop Web Testing, Mobile Web Testing, Native and Hybrid Mobile, based on your test requirements.
- URL to run test on: Provide the application URL that you want to test.
- Testing credentials for your web/mobile app to test functionality which requires user to login: You can provide the app’s user login credentials here and need not write them separately in the test steps then. The login functionality will be taken care of automatically using the keyword login. However, this is an optional field and can be skipped if not relevant.
- OS and Browser: Choose the OS Browser combination on which you want to run the test cases.
- Number of test cases to generate using AI: You can simplify your test creation further by opting to generate test cases based on the App Description text. This feature works on generative AI.
Step 3: Click on Create Test Suite.
Note: On the next screen, you can let AI generate the test case based on the App Description you provided during the Test Suite creation. However, for now, select do not generate any test, since we will write the test steps ourselves.
Step 4: To create a new custom test case yourself, click Add Custom Test Case.

Testing with AI-based reusable rules
The test case that we are going to look at is to search for a product through the search bar on an e-commerce site and submit a review for that product.
We will be using Reusable Rules in this guide to see how easily testRigor does all the heavy lifting for you.
Step 1: Come to the Test Cases section, provide the test case Description, and start adding the test steps. We will add test steps in the test case editor screen. Since we provided the website URL during test suite creation, testRigor automatically navigates to this website. There is no need to use a separate function to open the URL.

Here’s how the testRigor test script for this operation will look:
enter "Voyage Yoga Bag" in "search" enter enter

Step 3: After searching for the desired product, we are brought to the search landing page that comprises of a list of results. We need to scroll through them and click on the right product. We will let testRigor use generative AI to do this.
If you write a descriptive test step like
click on "Voyage Yoga Bag" in the catalog section below "search"
Then, testRigor scrolls to find the exact product. This is how testRigor interprets the above command during execution:
click "https://magento.softwaretestingboard.com/voyage-yoga-bag.html"

- An AI-based rule: This is what we will use in this guide. You need to provide a descriptive rule description/name, and testRigor’s AI engine will save it as a Reusable Rule while also using it in the test case.
- Convert it into an existing rule: You can use any of your existing Reusable Rules instead of this unrecognized statement.
- Create an empty rule: You can create a rule with no steps in it. This is especially useful in a BDD framework where tests are designed before the platform that will be tested. This also helps in cases where project managers want to copy and paste the scenarios from their test management tools, such as TestRail, Zephyr, PractiTest, ALM, etc.
- Comment it out: You can always comment out statements that don’t work or don’t make sense. You can revisit them later.
You can also parametrize or provide exact values to your reusable rules. To do this, use double-quoted strings ” ” within the rule steps or rule name.

For this example, we selected ‘Create AI-based rule’ and clicked ‘Update’.
Step 4: On the product page, we will click on the link that lets us write a review.
click on "Add your review"

Step 5: We will again use testRigor’s AI-based reusable rule to fill in the review form.
Here’s the rule:
Fill out the review form by selecting "3 stars" above "Nickname", entering nickame as "Vicky" in "NickName", a summary, and a review

If you provide descriptive names, the AI engine can do the rest of the work for you.
For example, for the above rule, testRigor filled out ‘Good but could be better’ in Summary and ‘The bag is spacious and durable, but it could use more pockets for better organization’ in Review.
Step 6: Once you’ve filled in the details, submit the form.
click on "Submit"

Observe how testRigor easily finds the button ‘Submit Review’ even though you just wrote ‘Submit’.
Here’s how the complete test case will look:
enter "Voyage Yoga Bag" in "search" enter enter click on "Voyage Yoga Bag" in the catalog section below "search" click on "Add your review" Fill out the review form by selecting "3 stars" above "Nickname", entering nickame as "Vicky" in "NickName", a summary, and a review click on "Submit"

That’s it! No complex XPath/CSS locators, just provide plain English statements, and testRigor’s AI will simply execute your automated test cases.
Viewing Test Results
Once the test is executed, you can view the execution details, such as execution status, time spent in execution, screenshots, error messages, logs, video recordings of the test execution, etc. In case of any failure, logs and error text are available easily with a few clicks.

You can also download the complete execution, including steps and screenshots, in PDF or Word format through the View Execution option.
How Self-healing works for Reusable Rules
When a test step fails because the UI/spec changed, testRigor tries an alternative way to complete the same intended action instead of failing right away (e.g., renamed buttons/labels, changed element attributes, or layout shifts).
What Auto-adapt Covers
- Locator Healing: Auto-adapt keeps tests stable by finding the correct UI element even when fragile locators (XPath/CSS/IDs) change, relying on end-user style identification like visible text and context instead of hardcoded selectors.
- Adapting to Specification Changes: Auto-adapt continues executing the intended step when the app’s wording or UI changes (for example, “Contacts” becomes “Prospects”) by using synonyms and AI-based self-healing to match the new equivalent element.
- AI-based Self-healing (Vision AI + rules/commands): Auto-adapt leverages Vision AI and auto-healing logic for rules and single commands to automatically adjust steps to UI changes and mark the run as healed (e.g., “fixed-by-ai”) for review.
How to Enable Auto Adapt for Reusable Rules
Option 1: From Setting Menu
Step 1: After creating the project, go to the Settings menu on the left side.

Step 2: Click on the AI Tab on the screen and then from the “Auto-adapt reusable rules with AI:” select the option: “Use AI to auto-adapt reusable rules“.

Option 2: From Reusable Rules Settings
Step 1: Go to the Reusable Rules Menu from the left side menu.

Step 2: On the Right side, there will be a dropdown, showing the value “Use AI to fix if global setting is enabled”

Step 3: If we have enabled self-healing for reusable rules in the Global Settings Page, we can see the message displayed as “Global setting is enabled“.

If it’s disabled in the global setting, then we can see “Global setting is disabled“.

Step 4: There are 3 options in the drop-down menu.

- Option 1: Use AI to fix if global setting is enabled
When choosing this option, if we enable use AI to fix reusable rules is selected in Global rules, then only self-healing will work for reusable rules. If it’s not selected, then self-healing won’t work for reusable rules.
- Option 2: Always use AI to fix
If the user chooses this option, then it will override whatever option is selected in the Global setting. Even if in Global setting, self-healing is disabled for reusable rules, it will get enabled by choosing this option.
- Option 3: Never use AI to fix
If in Global setting, the self-healing is enabled, then it will get disabled by choosing this option here.
To see the Self-healing capability in action, you can see the article: Self-healing Tests
Some More Interesting Capabilities of AI Reusable Rules
- Find and Substitute Similar Reusable Rules During Import: TestRail, XRay, Zephyr, Azure DevOps, etc., testRigor AI will check for similar rules and replace commands if a match is found. The matching process will compare customer commands with built-in commands, built-in rules, and customer rules.
- Replace Values Using AI in Parametrized Reusable Rules: testRigor automates the selection and parameterization of reusable rules. Once an AI selects a parameterized rule, it prompts for the necessary parameters and adds the configured rule to the test case. Read more about it over here: Rules and parameters using AI
testRigor’s Capabilities
- Reusable Rules (Subroutines): You can easily create functions for the test steps that you use repeatedly. You can use the Reusable Rules to create such functions and call them in test cases by simply writing their names. See the example of Reusable Rules.
- Global Variables and Data Sets: You can import data from external files or create your own global variables and data sets in testRigor to use them in data-driven testing.
- 2FA, QR Code, and Captcha Resolution: testRigor efficiently manages the 2FA, QR Code, and Captcha resolution through its simple English commands.
- Email, Phone Call, and SMS Testing: Use simple English commands to test the email, phone calls, and SMS. These commands help validate 2FA scenarios, with OTPs and authentication codes being sent via email, phone calls, or via phone text.
- File Upload/ Download Testing: Execute the test steps involving file download or file upload without the requirement of any third-party software. You can also validate the contents of the files using testRigor’s simple English commands.
- Database Testing: Execute database queries and validate the results fetched.
- Parallel Testing and CI/CD: For faster delivery cycles, you can completely rely on testRigor for parallel testing, AI, and automation testing to keep the CI/CD pipelines running smoothly.



