Turn your manual testers into automation experts!Request a Demo

testRigor Best Practices

Weekly Newsletter
Receive weekly testRigor newsletters packed with insights on test automation, codeless testing, and the latest advancements in AI.

testRigor Best Practices

There are several best practices you can follow to make your tests more stable, reliable, and easier to deal with.

Overall, generic test automation best practices are discussed here. We will get into more details related to testRigor usage.

When building tests, you want to make sure that your tests are:

  1. Use home URL for web tests
  2. Repeatable
  3. Refer to edits by labels
  4. Every large action should end with a validation
  5. Easy to read and understand
  6. Must be written from end-user’s perspective
  7. Should have no duplicated code
  8. Independent from each other so that they can run in parallel
  9. Test data and specifically test credentials are stored in test data
  10. One testRigor test case for one test
  11. Avoid using arbitrary waits
  12. Use built-in email functionality
  13. Use built-in login functionality
  14. Use built-in table functionality to work with tables
  15. Use built-in functionality to assess high-level colors

Use home URL for web tests

When creating a web test suite (either web on desktop or web on mobile) you are providing a home URL which is already opened by testRigor in the browser when you start a test. There is no need to use open url command to open the same URL again. This is very helpful since it makes it easier to:

  1. Share the same tests with your mobile app
  2. Substitute your home URL when triggering test suite via CI/CD to run on a different environment
  3. Keep your tests shorter, faster and more readable

Make tests repeatable

To make tests repeatable, you want to make sure they would run multiple times, not just once. It can be achieved by generating and creating test data you need in your test within the test. To generate data, you can use generate command. Then you’ll be able to store the value of generated data in variables (stored values) and use it later in the test. It is advisable to use Reusable Rules to create data. You can name them something like Create New Lead like this:

click "Leads"
click "New Lead"
generate unique name, then enter into "First Name" and save as "generatedFirstName"
generate unique name, then enter into "Last Name" and save as "generatedLastName"
generate unique name, then enter into "Company" and save as "generatedCompany"
generate unique email, then enter into "Email" and save as "generatedEmail"
click "Create"
check that page contains "Created"

In this code above, the Create New Lead rule will create a new lead, save the data about the lead into variables for future use and wait until the create action is complete and confirmation that it had been complete is visible on the page making it possible to continue without any delays if further actions are performed on the newly created lead. It could be used in a test case like this:

login
...
Create New Lead
click "Leads"
check that table at the row containing stored value "generatedLastName" and column "Status" contains "Created"
click "email" on the right of stored value "generatedLastName"

As you can see above we relied on unique values of the generated data to keep the test repeatable every time and stable.

Refer to edits by labels

testRigor has built-in functionality that automatically connects whatever looks like a label for an input element to the input element. So that you can refer to that element by that “label” even if it is technically is not a label element. For example, instead of relying on low-level elements like ids:

...
enter "Peter" into "name_input_3"

you are better off using visible labels like so:

...
enter "Peter" into "First Name"

this would continue to work even if your “label” text will migrate from top to the left of the input or will be replaced by a placeholder.
It will also make sure your tests are more stable and resilient to changes in details of implementation like ids.

Every large action should end with a validation

If you don’t have validation at the end of your test, you don’t know if your last action succeeded. For instance, if you clicked on a button, you don’t know if it worked or not. By adding validation at the end of the test, you’ll verify that what you expected to happen actually happened.

...
click "Submit"
check that page contains "Submitted successfully"

On top of that, testRigor has a built-in functionality that will retry tap or click if the next command fails, so it is beneficial to have a validation after most of the clicks/taps to make sure that the action succeeded.

...
click "Submit"
check that page contains "Submitted successfully"
click "Orders"
check that table "Orders" at first row contains "Submitted"
click table "Orders" at first row and column "Id"
check that page contains "Submitted"

Tests should be easy to read and understand

To make your tests easy to read and understand, you should always try to use visible texts and create human-readable Reusable Rules.

...
enter "Peter" into "First Name"
enter "Gosling" into "Last Name"
click "Submit"
Process Submitted Contact

Additionally, test cases can be greatly improved by using comments to specify where a reusable rule is, what exactly this part of the test does and divide the test into distinct steps.

...
// Step 3
go to registration form // reusable rule

// Fill in registration form
// Step 4
enter "John" into "First Name"
enter "Doe" into "Last Name"

// Step 5
click "Register"
check that page contains "Registration complete"

Tests must be written from end-user’s perspective

This is the most important best practice of them all. Anything you create as a test must be done purely from end-user’s perspective, without relying on details of implementation as much as it is possible.

Specifically:
  1. You want to avoid using ids/css classes/etc as much as possible, because they can change at any point in the development. You can often rely on relative location as much as you can. Try to rely on sections like so: enter "584 Castro St" into "address" in the section "From"
  2. Also, you want to avoid relying on ids/names for inputs and rely on the labels (or placeholder text) instead
  3. In cases if it is not possible (you are clicking on an icon, for example), try to extract the part of CSS class that is the most descriptive of what this button does. For example, instead of click "btn-requester-list-grid-clear-filter" use click "clear-filter"

Tests should have no duplicated code

If you notice that you are about to copy-paste some code to another test or this code was already copy-pasted, create a Reusable Rule and use that rule instead of those lines of code as described in the section Making tests repeatable.

You should also search for existing Reusable Rules potentially already created by your colleagues before building a new one.

It is a good practice to start a Rule with validation to make sure it is applicable and fails early, as well as end it with validation to make sure that rule actually succeeded.

Always make sure that the rule name is as descriptive as it is possible.

Tests should be independent from each other so that they can run in parallel

Similar to what we talked about section Making tests repeatable, try to create the unique data used in the test so that all of your tests will be able to run in parallel. This will greatly benefit the performance of the test suite once the number of tests is large enough, and you’ll add more parallelization for the test execution.

There should never be any dependency between any test cases because they all might run in parallel. If you need to have some data generated or setup for other test cases, you should use reusable rules generating unique data, or, if data doesn’t need to be unique, use the test suite’s before-hook that you can edit on the top of test cases page in test suite hook section.

Test data and specifically test credentials are stored in test data

If you use some test data that might change in the future and/or any credentials, they should be stored in the test data section. This will allow you to hide passwords and easily update data in one place once it changes, even if it is used in multiple tests.

One testRigor test case for one test

Even though the test cases in your test case management system might be very large and all-encompassing, you should try to create as granular test cases in testRigor as it is technically possible to be able to run them faster and take better advantage of parallelization.

Avoid using arbitrary waits

All testRigor commands have built-in waiting for element on the screen. It will wait until element is there before executing the command. Therefore you should avoid using arbitrary waits because you don’t know how long does it take for element to appear on the screen. It can vary run by run in some situations and on one run it could be 1 second and on another run it could be 20 seconds, which makes wait 10 seconds command useless waste of time. So instead of:

click "Login"
wait 10 seconds
click "Orders"

You should do:

click "Login"
check that page contains "Dashboard"
click "Orders"

The command check that page contains "Dashboard" will wait by default up to 30 seconds (you can always adjust it in settings) until page will contain the “Dashboard” text.

There is one exception to this rule and this is when you have a very long running job that might take minutes to complete. In this case you can use conditional wait that will do it and wait for more that 20 seconds:

click "Start Job"
wait up to 5 minutes until page contains "Job Complete"
click "Results"

However, in majority of the situations this is unnecessary and built-in waits would do fine job if you add the appropriate validations alongside.

Use built-in email functionality

Use email functionality to check emails and extract data from emails. Like check that email from "[email protected]" was received instead of trying to rely on 3rd-party email providers. testRigor provides first-class email provider out of the box to make sure you can do high-quality email verifications and interactions with email as efficiently as possible.

Use built-in login functionality

Use login and other built-in testRigor reusable rules to allow you to auto-adapt to changes in your login flow and keep your tests as stable as possible without doing any code changes. For example, testRigor’s login built-in rule will continue working even if your login process will migrate to 3rd party identity provider or switch from one step login to two step login, the built-in login rule will continue to work as expected.

Use built-in table functionality to work with tables

testRigor has built-in ways to refer to elements in tables irregardless how those tables are rendered. This will allow your tests to withstand changes of tables rendering even if the table rendering will change from TR/TD-based to DIV-based rendering. And it will make your tests more stable. For example, you can do things like:

click on table "actions" at row "103" and column "Action"

You can learn more about it here and read documentation here and here.

Use built-in functionality to assess high-level colors

Often times when we validate colors we don’t care about the specific shades of it. For example, when we validate that border of an input is now red to indicate an issue we don’t care what shade of red it is, we just care that it is red. If the shade of the color were to change later it shouldn’t break the test, since you don’t care about the shade, you care that it still alert the user that the value of the input is incorrect.
It is possible to validate just the high-level color with testRigor like so:

check that input "First Name" border color looks red

testRigor will validate that the specific color of the border looks red to a human (based on scientific research). You can learn more about it here.

Privacy Overview
This site utilizes cookies to enhance your browsing experience. Among these, essential cookies are stored on your browser as they are necessary for ...
Read more
Strictly Necessary CookiesAlways Enabled
Essential cookies are crucial for the proper functioning and security of the website.
Non-NecessaryEnabled
Cookies that are not essential for the website's functionality but are employed to gather additional data. You can choose to opt out by using this toggle switch. These cookies gather data for analytics and performance tracking purposes.