Turn your manual testers into automation experts! Request a DemoStart testRigor Free

How to use variables in testRigor?

Using variables while writing test cases is helpful for many reasons. It not only makes your test case more versatile, as you can easily update values at a single repository as opposed to throughout the test suite, but it also allows you to use the same test case for different data. testRigor makes using variables very easy through its simple English commands. Let’s take a look at what it has to offer in this aspect.

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.

Step 2: Set up the test suite for the website testing by providing the information below:

  • 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.

Test Case: Fill a form using testRigor’s variables

In the following test case, we will fill out a form while using variables.

Let’s take a look at every step that will be part of the testRigor test case.

Test Steps

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.

Step 2: 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. The form that we are going to fill out looks like this.

Step 3: testRigor lets you store values as variables in the Test Data section of your Test Suite. You can either create global variables or data sets. Once you’ve created your test data, you can use it across test cases by referring to it using the keywords ‘stored value’ before the variable name.

In our test case, we’ve created multiple global variables that we will use to fill out the form. When it comes to global variables, you can create different kinds of variables where the data can be of type text, multi-line, hidden (like in passwords), or file.

Here’s a video on how you can create a variable in the Test Data section.

Step 4: In our form, the first field we will fill is the ‘First Name’ field. We have created a variable ‘firstName’ in the Test Data section for the ‘First Name’ field’s value.
enter stored value "firstName" into "First Name"
Step 5: Let’s fill rest of the form as well. After the first name, we will add the last name using the value stored in the ‘lastName’ variable.
enter stored value "lastName" into "Last Name"
Step 6: Enter the email address from the stored value (variable) ’email’ into the correct field.
enter stored value "email" into "Email"
Step 7: testRigor also supports generating random values using RegEx. The below command creates a random 10-digit mobile number. Since we don’t want our mobile number to start with a 0, we have given the condition to pick any digit between 1 and 9 ([1-9]). The remaining nine digits can be anything between 0 to 9. Hence, we write it as [0-9]{9} where the {9} specifies how many places this condition holds true for.
generate by Regex "[1-9][0-9]{9}" then enter into "Mobile Number"

Step 8: Finally, we will check if the page shows the current date by default in the ‘Date of Birth’ field. For that, we will use testRigor’s feature to use variables as parameters. You can write expressions like mathematical expressions, expected URL structures, or strings using stored variables. testRigor simplifies this process by providing a pre-defined set of values as variables like the current date, year, month, time, test URL, etc.

For our test case, we want to check a string that gives the current date in the format ‘DD Mmm YYYY’. To write variables as parameters, you need to enclose the variable name in {} and prefix it with a $ symbol. This will tell testRigor what to treat as parameters within the quotation marks.
check that page contains string with parameters "${todayDayOfMonthTwoDigits} ${todayMonthShort} ${todayYear}"

This is how the form looks after being filled.

Complete test case

Here’s what the whole test case will look like in testRigor.
enter stored value "firstName" into "First Name"
enter stored value "lastName" into "Last Name"
enter stored value "email" into "Email"
generate by Regex "[1-9][0-9]{9}" then enter into "Mobile Number"
check that page contains string with parameters "${todayDayOfMonthTwoDigits} ${todayMonthShort} ${todayYear}"

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 in a few clicks.

You can also download the complete execution with steps and screenshots in PDF or Word format through the View Execution option.

testRigor’s Capabilities

Using variables in testRigor is super easy. There’s a lot more you can test with this tool.

  • 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.

Additional Resources

FAQs

  1. Can I hard-code test data values in test cases?

    Though creating variables might seem like a mini detour, making hard-coding test data values into the test case appealing, using variables is always advisable. testRigor supports both of these capabilities. In fact, if you hard-code test data, maintaining these test cases becomes cumbersome at a later stage as opposed to using variables whose values can easily be updated.

  2. Do I need to create variables separately to do data-driven testing?

    If you need to use a dataset (multiple data values) for a test case, you can upload a .csv file in the Test Data -> Data Sets section. This will allow you to upload multiple values for the same variable in one go. Check out this detailed guide on data-driven testing.

Join the next wave of functional testing now.
A testRigor specialist will walk you through our platform with a custom demo.
Related Articles

How to Install Client Certificates in testRigor

Client certificates are one of several ways to allow users to authenticate their identity to a server, most often a private ...

How to do database testing using testRigor?

Database testing is crucial because it ensures the integrity and reliability of your application’s data. It verifies the ...

How to perform keyboard actions using testRigor?

Smart test automation tools like testRigor account for various ways for testers to interact with the system. You can copy and ...