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

How to Automate 2FA Login with TOTP using testRigor?

TOTPs or time-based OTPs are a popular way of performing 2-factor authentication. They add an extra layer of security to logins by requiring two forms of verification: something you know (like your password) and something you have (like a temporary code generated by an app). You can achieve this using apps like Google Authenticator, Microsoft Authenticator, or others.

testRigor supports 2FA login with OTPs generated through the Google Authenticator app with simple steps. Here’s how you can do it.

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 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: Once you add the details, click on Create Test Suite.

On the next screen, you can let AI generate the test case based on the app description you provided while creating the Test Suite. However, for now, select do not generate any test, since we will write the test steps ourselves.

Step 4: The actual command that testRigor needs to do the TOTP-based 2FA login for you is pretty simple. However, before we write that single line, we need to get the image of the 2FA QR code from your Google Authenticator app and save that as a file in testRigor’s Test Data section.

Here’s a detailed step-by-step guide on how to do that – Google Authenticator Support for Gmail 2FA

Now that you’ve done the pre-requisite, let’s get to writing the test case in testRigor.

We will be logging into our Gmail account, which requires a 2FA login with TOTP.

Step 5: To create a new custom test case, click Add Custom Test Case.

Step 6: Since we added the URL to the Gmail login page, we will land on the required page. We will provide the email id in the field Email or Phone. In this test case, we are storing the email id in a variable named “test-gmail” in the Test Data section.
enter stored value "test-gmail" into "Email or Phone"
Step 7: Go to the Enter Password screen by clicking on Next.
click "Next"
Step 8: Enter the password in the field Password. Here as well, we are storing the password in a variable named “test-gmail-pass” in the Test Data section.
enter stored value "test-gmail-pass" into "Password"
Step 9: Go to the 2FA screen by clicking on Next.
click "Next"
Step 10: Now we want testRigor to use the QR code from the Test Data to generate the TOTP and save it in a variable named “code”.
generate PIN with google authenticator from stored value "MyQrCode" and save as "code"
There are a couple of acceptable statements that testRigor’s AI-powered engine can interpret to do this operation. This gives you more flexibility when crafting test cases.
generate pin with google authenticator from stored value "qr-code" and save as "out-variable"
generate code with google authenticator from stored value "qr-code" and save as "out-variable"
generate google authenticator code from stored value "qr-code" and save as "out-variable"
generate google authenticator pin from stored value "qr-code" and save as "out-variable"
generate google code from stored value "qr-code" and save as "out-variable"
generate google pin from stored value "qr-code" and save as "out-variable"

In the above commands, “qr-code” refers to the actual google authenticator QR code image saved in your Test Data, and “out-variable” is a variable to hold the code.

Step 11: Enter this code into the relevant field.
enter stored value "code" into "Enter code"
Step 12: Click on Next to move ahead.
click "Next"

The complete test case will look like this:

enter stored value "test-gmail" into "Email or Phone"
click "Next"
enter stored value "test-gmail-pass" into "Password"
click "Next"
generate PIN with google authenticator from stored value "MyQrCode" and save as "code"
enter stored value "code" into "Enter code"

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, including steps and screenshots, in PDF or Word format through the View Execution option.

testRigor’s Capabilities

With testRigor, you can test end-to-end test cases across various platforms like the web, desktop, and mobile platforms. Using simple English commands, you can do the following.

  • 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.
  • Test AI features: This is an era of LLMs, and using testRigor, you can even test LLMs such as chatbots, user sentiment (positive/negative), true or false statements, etc. Read: AI Features Testing.
  • Cross-browser and cross-platform support: The tool allows you to perform cross-browser and cross-platform tests; parallel execution feature allows you to get the test results in minutes.
You're 15 Minutes Away From Automated Test Maintenance and Fewer Bugs in Production
Simply fill out your information and create your first test suite in seconds, with AI to help you do it easily and quickly.
Achieve More Than 90% Test Automation
Step by Step Walkthroughs and Help
14 Day Free Trial, Cancel Anytime
“We spent so much time on maintenance when using Selenium, and we spend nearly zero time with maintenance using testRigor.”
Keith Powe VP Of Engineering - IDT
Related Articles

Import test cases from XRay for execution with testRigor

To ensure good software testing, you need more than test management. You need to be able to integrate with other testing tools to ...

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 ...
On our website, we utilize cookies to ensure that your browsing experience is tailored to your preferences and needs. By clicking "Accept," you agree to the use of all cookies. Learn more.
Cookie settings
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.