- getting started
- Get Started with Automating Web Applications
- Get Started with Automating Mobile Web Applications
- Get Started with Automating Android Apps
- Get Started with Automating iOS Apps
- Get Started with REST API Testing
- test cases
- web apps
- How to create web application tests using Test Recorder
- How to create Test Steps for uploading files
- mobile apps
- How to create Android & iOS app tests using Test Recorder
- How to automate Android app tests using local devices
- How to automate iOS app tests using local devices
- How to automate data driven testing
- REST API
- What is JSONPath and How to query JSON using JSONPath
- Contract Testing with Testsigma
- Consumer Driven Contract Testing with Testsigma
- test plans
- How to create test plans to run on your local devices
- How to do cross-platform end-to-end testing with Testsigma
How to automate SMS based two factor authentication(2FA)
Prerequisites
Steps to automate SMS based OTP verification
Step 1: Record elements
Before moving on to the test case, you must capture elements on the login screen of your application. For more information on how to record elements using Testsigma chrome recorder extension, refer to
Step 2: Configuring your phone number
Testsigma provides you with a valid mobile phone number on request, with which you can author any test case that requires a valid phone number.
The 2FA testing (email and phone number) is offered as part of the enterprise plan. The feature is available for the below mentioned countries & supported for SMS OTP.
Australia, Canada, USA, Czech Republic, Denmark, Hungary, Indonesia, Mexico, Netherlands, Romania, Slovakia, Sweden, United Kingdom. For other regions, contact sales.
To view the phone numbers allocated to your account, navigate to Settings> Phone numbers.
Step 3: Create a test case
If you are not familiar on how to create a simple test case, refer to create a testcase.
Step 4: Create a test step to enter the phone number to which the OTP will be sent
We will enter the phone number provided by Testsigma using the Phone Number test data type, using a test step.
- In your test case, add a test step to enter the phone number in the phone number field on your application page.
- Clear the < test data > placeholder and select the %|Phone Number| test data type from the suggestions list. An overlay showing the list of available phone numbers (allocated to your account) would open up.
- Select one of the numbers from the list. This is the number where the OTP SMS will be sent.
- Next, use the NLP Click on SendOTP
Step 5: Create a test step to fetch the OTP from the SMS received on the Phone number
We will use the test data generators available in Testsigma to fetch the OTP from the phone number selected in the previous step.
- Add a test step to enter the OTP code in the OTP Field
- Clear the < test data > placeholder and select the !|Function| test data type
- Search and select the test data generator function !|PhoneNumberFunctions - getOTP|
- Enter the following arguments for the function and create the test step.
- Regex: The Regex command specifies the format of the OTP i.e alphanumeric or pure number or pure alphabetical etc. For example: for an OTP which is a number with a length of 4 to 8, we can use the regular expression \d{4,8}.
- Phone number: This field specifies one of the pre-configured phone numbers, in this case its +12082045810
- Timeout: Duration of the wait time for the OTP to be generated
Once these values are passed the PhoneNumberFuntion will use the parameters to read the generated OTP.
The below GIF depicts the method to automate email based OTP verification in real time using a sample application: