Joke Collection Website - Public benefit messages - Solution of automatically obtaining SMS check code

Solution of automatically obtaining SMS check code

With the popularity of online real-name registration system in recent two years, many systems need to authenticate their real names through SMS verification, which brings great challenges to the development of automated test scripts. Take the auto insurance underwriting system I am responsible for as an example. In the process of handling commercial insurance, it involves the test scenario of SMS verification, and the specific business process is shown in the following figure.

To realize the automatic test of the above business processes, the most critical point is to automatically obtain the SMS check code. In order to solve this problem, my team envisaged three schemes:

The first scheme is to intercept short messages sent by commercial platforms to users from the background. This scheme looks beautiful, but its problem is that the SMS check code is issued by a third-party platform. Interception and analysis of messages in the background is not only costly, but also may violate the bottom line of network security, which is not feasible.

The second scheme is to make a fuss from the mobile phone, develop a mobile phone application to forward the verification code message to the mailbox, and then log in to the mailbox on the computer to get the verification code. This method is feasible, but there is a risk of network delay.

The third scheme is to develop a mobile phone application to analyze the SMS check code and write it into the mobile phone memory file, and then copy the check code file to the computer through USB connection and read the local file to obtain the check code. Because the third scheme avoids the risk of network delay compared with the second scheme, we choose it as the final solution.

? First, Android phone configuration

1. Based on the Android system, an APK is developed to parse the SMS check code and write it into the mobile phone memory file. We named it SmsTest.

2. Install SmsTest on Android phone. After installation, you can see the following icons on the phone desktop.

3. Open all permissions of SmsTest application.

4. Open the mobile phone developer mode and turn on USB debugging.

? Second, the computer configuration

1. Install JDK and configure environment variables.

2. Install SDK and configure environment variables.

Please refer to the first and third steps of/dr _ neo/article/details/49870587 for specific steps. After installing SDK, enter ADB instruction in the command line window to test. If you see the following prompt, the SDK configuration is successful.

3. Install the Android USB driver.

3. Obtain the platform check code

1, the mobile phone starts the SmsTest applet.

2. Connect the mobile phone to the computer through USB cable, and select the file access right in the prompt message that pops up on the mobile phone.

3. Call the getSms method in the automated test script to obtain the check code sent by the platform.