Automation the testing of application sending sms

4.9k Views Asked by At

I'm trying to automate the application using Selenium WebDriver. My application sends sms with confirmation code which is used in turn to confirm the changes on web-page. Could you advise please how can I automate this functionality? Where can I extract the confirmation code sent by sms? Thank you!

2

There are 2 best solutions below

0
On

I suppose you have to test the following scenario:

  1. User goes to the site and ask something then site sends sms to the user.
  2. User entries the received confirmation code to some site field and the user o some site service will available.

I suppose that your intention to test just the site behaviour but not functionality of sending and receiving SMS. I also suppose that the confirmation code is not expired.

In order to test just this functionality I suggest to use the predefined scenario. You will take the confirmation code that you have from the manual test and use it in your web site selenium automation. This is good enough to verify described functionality.

In case if the confirmation code has the expiration period I suggest to use the code that developers use in order to build this confirmation code in your method.

The last option (if you don't have access to the development code) - using the mobile automation (like appium) with the mobile simulator in order to receive the confirmation code. In this case the site will send the sms to the mobile simulator (please see this question how to simulate the mobile device number) and your appium code will take it and save in the local file. Then the selenium code will use it. This approach much more complicated but will cover end to end scenario.

0
On

If you use testRigor system it has built-in way to test SMS and your code would look like this:

click "Sign in"
enter "user" into "Username"
enter "password123" into "Password"
click "Verify me"
check that sms to "+12345678902" is delivered and matches regex "Code\:\d\d\d\d" and save it as "sms"
extract value by regex "(?<=Code\:)[0-9]{4}" from "sms" and save it as "confirmationCode"
enter saved value "confirmationCode" into "code"
click "Continue to Login"
check that page contains text "Welcome, Peter!"