Wechat applet automatic login method and device based on jmeter and storage medium

By combining JMeter and WeChat Developer Tools, temporary login credentials and token values ​​for WeChat Mini Programs can be automatically obtained, solving the tedious problem of manually obtaining codes in WeChat Mini Program development and realizing an efficient automated login process.

CN116566659BActive Publication Date: 2026-03-20SHANGHAI ZHONGTONGJI NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-19
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In existing technologies, WeChat Mini Program development and debugging require manual periodic acquisition of code to obtain tokens, resulting in low software development efficiency. Furthermore, the JMeter tool cannot automatically obtain the WeChat Mini Program authorization login code, thus blocking the automation process.

Method used

The project path of the WeChat Mini Program is obtained through the JMeter tool. The wx.login() method is called using the WeChat Developer Tools to obtain a temporary login credential. The token value is set as a global variable and passed into the request header information of subsequent interfaces of the JMeter tool. The full-link script is executed periodically.

Benefits of technology

It enables automatic login for WeChat mini programs, reducing the number of times code needs to be manually obtained, simplifying the process, and improving development efficiency and the execution efficiency of automated scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116566659B_ABST
    Figure CN116566659B_ABST
Patent Text Reader

Abstract

The application provides a WeChat applet automatic login method and device based on JMeter and a storage medium, relates to the technical field of software development, and the method acquires the project path of the WeChat applet by using the JMeter tool according to the APP ID provided by WeChat; then the WeChat developer tool is started, the wx.login() method is called to acquire the temporary login credential, and whether the temporary login credential corresponds to the WeChat applet is judged; if the temporary login credential corresponds to the WeChat applet, the token value is acquired by calling the temporary login credential by using the login interface of the WeChat applet, the token value is set as a global variable, then the token value is transmitted into the request header information of the subsequent interface of the JMeter tool, and the JMeter full-link script is executed regularly. The application reduces the number of times of manually acquiring the code before executing the script each time, and realizes the automatic login of the WeChat applet by using the JMeter tool.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of software development, and particularly relates to a method and device for realizing automatic authorization login of a WeChat applet based on a JMeter tool and a storage medium. BACKGROUND

[0002] JMeter is a test tool developed using Java and free of charge, and is mainly used for function test and performance test.

[0003] In the prior art, the code or token value must be obtained through a WeChat developer tool for WeChat applet development and debugging, and the code is valid for only 5 minutes, so the code needs to be manually obtained at regular time intervals to obtain the token for login, which results in low software development efficiency.

[0004] At the same time, the WeChat applet interface automation cannot automatically obtain the code after the WeChat applet authorization login through the JMeter, because the login applet content calls the wx.login() method, and the code is real-time changeable, which blocks the automatic flow from the beginning of each script execution, and the script dependent on login cannot be executed at regular time intervals. SUMMARY

[0005] Therefore, the application provides a WeChat applet automatic login method and device based on JMeter and a storage medium, which helps to solve the problem that the WeChat applet automatic login cannot be realized through the JMeter tool in the prior art.

[0006] To achieve the above object, the application adopts the following technical solutions:

[0007] In a first aspect, the application provides a WeChat applet automatic login method based on JMeter, comprising:

[0008] obtaining the project path of the WeChat applet by using the JMeter tool according to the APP ID provided by WeChat;

[0009] starting the WeChat developer tool, calling the wx.login() method to obtain a temporary login credential, and judging whether the temporary login credential corresponds to the WeChat applet;

[0010] if the temporary login credential corresponds to the WeChat applet, using the login interface of the WeChat applet to call the temporary login credential to obtain a token value, and setting the token value as a global variable;

[0011] transmitting the token value into the request header information of the subsequent interface of the JMeter tool, and executing the JMeter full-link script at regular time intervals.

[0012] Further, the project path of the WeChat applet is obtained by using the JMeter tool according to the APP ID provided by WeChat, and specifically includes:

[0013] The APP ID and the absolute path of the WeChat applet are obtained through the interface provided by WeChat, and the corresponding project package of the WeChat applet is downloaded locally;

[0014] The project path corresponding to the WeChat applet is obtained according to the APP ID and the absolute path of the WeChat applet by using the Beanshell sampler in the JMeter tool.

[0015] Further, the WeChat developer tool is started, the wx.login() method is called to obtain a temporary login credential, and it is judged whether the temporary login credential corresponds to the WeChat applet, and specifically includes:

[0016] The automator.launch() method is called to start the WeChat developer tool, then the miniProgram.callWxMethod() is called to call the wx.login() method to obtain a temporary login credential, and it is judged whether the temporary login credential corresponds to the APP ID of the WeChat applet.

[0017] Further, the token value is obtained by calling the login interface of the WeChat applet with the temporary login credential, and the token value is set as a global variable, and specifically includes:

[0018] The login interface of the WeChat applet is called to log in to the WeChat applet with the temporary login credential, and the token value is obtained by requesting the login interface to pass parameters through the Beanshell sampler in the JMeter tool;

[0019] The obtained token value is set as a global variable for subsequent interface calling.

[0020] In a second aspect, the application also provides a WeChat applet automatic login device based on JMeter, comprising:

[0021] A path obtaining unit is configured to obtain the project path of the WeChat applet by using the JMeter tool according to the APP ID provided by WeChat;

[0022] A credential data collecting unit is configured to start the WeChat developer tool, call the wx.login() method to obtain a temporary login credential, and judge whether the temporary login credential corresponds to the WeChat applet;

[0023] The token data collection unit is configured to, if the temporary login credential corresponds to the WeChat mini-program, call the login interface of the WeChat mini-program to obtain a token value by using the temporary login credential, and set the token value as a global variable.

[0024] The script execution unit is configured to pass the token value into the request header information of a subsequent interface of the JMeter tool, and execute a JMeter full-link script at a regular time.

[0025] In a third aspect, the present application provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the JMeter-based automatic login method of the WeChat mini-program provided in the first aspect.

[0026] The above technical solutions have at least the following beneficial effects:

[0027] The JMeter-based automatic login method of the WeChat mini-program provided in the present application comprises the following steps: obtaining a project path of a WeChat mini-program by using a JMeter tool according to an APP ID provided by WeChat; starting a WeChat developer tool, calling a wx.login() method to obtain a temporary login credential, and determining whether the temporary login credential corresponds to the WeChat mini-program; if the temporary login credential corresponds to the WeChat mini-program, calling the login interface of the WeChat mini-program to obtain a token value by using the temporary login credential, and setting the token value as a global variable; and passing the token value into the request header information of a subsequent interface of the JMeter tool, and executing a JMeter full-link script at a regular time. The present application finds the project path corresponding to the mini-program by using the JMeter tool to process the APP ID provided by WeChat, starts the WeChat developer tool by calling an automator.launch() method, and then calls a miniProgram.callWxMethod() to call the wx.login() method to obtain the temporary login credential. Therefore, the login interface of the mini-program calls the temporary login credential to generate the token value and set the global variable, which facilitates the subsequent other interface request header information to call and execute the JMeter full-link script, reduces the number of times of manually obtaining the code before executing the script each time, and solves the problem that the existing technology is difficult to automatically log in the WeChat mini-program by using the JMeter tool.

[0028] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings required by the embodiments or prior art description will be briefly introduced.

[0030] Figure 1 is a JMeter-based WeChat applet automatic login method flowchart according to an exemplary embodiment;

[0031] Figure 2 is a technical implementation flowchart according to an exemplary embodiment;

[0032] Figure 3 is a functional architecture diagram of a JMeter-based WeChat applet automatic login device according to an exemplary embodiment. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described in detail below.

[0034] Please refer to Figure 1 , Figure 1 is a JMeter-based WeChat applet automatic login method flowchart according to an exemplary embodiment, as shown in Figure 1 , the method comprises:

[0035] S1: According to the APP ID provided by WeChat, use JMeter tool to obtain the project path of WeChat applet;

[0036] S2: Start WeChat developer tool, call wx.login() method to obtain temporary login credential, and judge whether the temporary login credential corresponds to the WeChat applet;

[0037] S3: If the temporary login credential corresponds to the WeChat applet, use the login interface of WeChat applet to call the temporary login credential to obtain token value, and set the token value as global variable;

[0038] S4: The token value is transmitted into the request header information of JMeter tool subsequent interface, and JMeter full link script is executed regularly.

[0039] At present, test personnel use JMeter tool to do automatic script execution, need to manually obtain WeChat authorization code to get login token (i.e. token), manually fill in the request header information parameters of interface, so as to execute full process script.

[0040] This process is relatively complex, requiring manual modification of request header parameters each time, making it cumbersome. Therefore, this application utilizes the interface provided by WeChat, employing JMeter to call the WeChat Developer Tools, passing the Mini Program APP ID and absolute path to obtain the Mini Program project path. Combined with JavaScript, the miniprogram-automator automated testing tool is used to launch the WeChat Developer Tools, and then `miniProgram.callWxMethod()` is used to call the `wx.login()` method to obtain the code. This allows the WeChat Mini Program login interface request parameters to call the WeChat-provided interface to generate the code, thereby obtaining a token value. This token value is then set as a global variable for use in subsequent script request header information.

[0041] Furthermore, in one embodiment, obtaining the project path of the WeChat Mini Program using the JMeter tool based on the APP ID provided by WeChat specifically includes:

[0042] Obtain the WeChat Mini Program's APP ID and absolute path through the interface provided by WeChat, and download the corresponding Mini Program project package locally.

[0043] Using the Beanshell sampler in JMeter, the project path corresponding to the WeChat mini program is obtained based on the APP ID and the absolute path of the mini program.

[0044] Furthermore, in one embodiment, the step of launching the WeChat Developer Tools, calling the wx.login() method to obtain a temporary login credential, and determining whether the temporary login credential corresponds to the WeChat Mini Program specifically includes:

[0045] The `automator.launch()` method is called to launch the WeChat Developer Tools. Then, `miniProgram.callWxMethod()` is called to invoke the `wx.login()` method to obtain a temporary login credential, and it is determined whether the temporary login credential corresponds to the WeChat Mini Program's APP ID.

[0046] Furthermore, in one embodiment, the step of using the WeChat Mini Program's login interface to call the temporary login credential to obtain a token value and setting the token value as a global variable specifically includes:

[0047] The login interface of the WeChat mini program calls the temporary login credential to log in to the WeChat mini program, and at the same time, it requests the login interface to pass parameters and obtain the token value through the Beanshell sampler in the JMeter tool;

[0048] Set the obtained token value as a global variable for subsequent API calls.

[0049] Reference Figure 2 As shown, this application uses IntelliJ IDEA to develop WeChat's provided interface. It uses JMeter with the BeanShell sampler to process the WeChat-provided APP ID, finds the corresponding project path of the mini-program, calls the `automator.launch()` method to launch the WeChat developer tools, and then calls `miniProgram.callWxMethod()` to call `wx.login()` to obtain the code. The mini-program's login interface then uses the code to log in, generates a token value, and sets it as a global variable for subsequent API request header information. The specific technical implementation process for this part is as follows:

[0050] 1. Use the Beanshell preprocessor in JMeter to invoke the command of the tool that retrieves the WeChat Mini Program login code;

[0051] 2. The config.js file in the tool has already configured the APP ID and absolute project path of the mini-program for this project (a CSV file can also be used here for configurability, so as to facilitate later maintenance);

[0052] 3. Launch the WeChat Developer Tools by calling the automator.launch() method provided by WeChat;

[0053] 4. Then call the miniProgram.callWxMethod() method in the miniprogram-automator tool;

[0054] 5. Obtain the code by calling wx.login() based on miniProgram.callWxMethod(), and then determine whether the obtained code is the code of the corresponding mini program;

[0055] 6. Based on the obtained code, the JMeter sampler requests the login interface, passes the code parameter, and obtains the token value;

[0056] 7. Subsequent API request headers will pass in the token, thereby executing the JMeter full-chain script.

[0057] This application automates the WeChat authorization login process through code, obtains the code, and further obtains the token, reducing the number of times the code needs to be manually obtained before each script execution. This allows the token to be obtained and the header parameters of other interfaces to be modified before executing the JMeter full-chain script.

[0058] Referring to Figure 3 As shown in the specification, the application also provides a JMeter-based WeChat applet automatic login device, comprising:

[0059] A path acquisition unit is configured to acquire a project path of the WeChat applet by using a JMeter tool according to an APP ID provided by WeChat;

[0060] A credential data acquisition unit is configured to start a WeChat developer tool, call a wx.login() method to acquire a temporary login credential, and determine whether the temporary login credential corresponds to the WeChat applet;

[0061] A token data acquisition unit is configured to, if the temporary login credential corresponds to the WeChat applet, acquire a token value by using a login interface of the WeChat applet to call the temporary login credential, and set the token value as a global variable;

[0062] A script execution unit is configured to pass the token value into request header information of a subsequent interface of the JMeter tool, and execute a JMeter full-link script at a regular time.

[0063] The application can automatically acquire a WeChat applet code in the process of developing and using the WeChat applet, log into the WeChat applet successfully according to the acquired code, place a generated token in request header information of a subsequent interface, and realize automatic script running at a regular time.

[0064] In addition, the application provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute steps in the JMeter-based WeChat applet automatic login method provided in the first aspect.

[0065] It can be understood that the same or similar parts in the above-mentioned embodiments can be mutually referred to, and contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.

[0066] In the description of the specification, the description of the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the application. Although the embodiments of the application have been shown and described above, it can be understood that the above-mentioned embodiments are exemplary and cannot be understood as limiting the application, and those skilled in the art can make changes, modifications, replacements and variations to the above-mentioned embodiments within the scope of the application.

Claims

1. A method for automatic login of WeChat mini-programs based on JMeter, characterized in that, include: Based on the APP ID provided by WeChat, use the JMeter tool to obtain the project path of the WeChat mini program; The automator.launch() method is called to launch the WeChat Developer Tools, and then miniProgram.callWxMethod() is called to call wx.login() to obtain a temporary login credential. The temporary login credential is then checked to see if it corresponds to the APP ID of the WeChat Mini Program. If the temporary login credential corresponds to the WeChat mini program, then the login interface of the WeChat mini program is used to call the temporary login credential to obtain the token value, and the token value is set as a global variable; The token value is passed into the request header information of subsequent interfaces of the JMeter tool, and the JMeter full-link script is executed periodically.

2. The automatic login method for WeChat mini-programs based on JMeter according to claim 1, characterized in that, The specific steps for obtaining the WeChat Mini Program's project path using JMeter based on the WeChat-provided APPID include: Obtain the WeChat Mini Program's APP ID and absolute path through the interface provided by WeChat, and download the corresponding Mini Program project package locally. Using the Beanshell sampler in JMeter, the project path corresponding to the WeChat mini program is obtained based on the APP ID and the absolute path of the mini program.

3. The automatic login method for WeChat mini-programs based on JMeter according to claim 1, characterized in that, The step of using the WeChat Mini Program's login interface to call the temporary login credential to obtain a token value and setting the token value as a global variable specifically includes: The login interface of the WeChat mini program calls the temporary login credential to log in to the WeChat mini program, and at the same time, it requests the login interface to pass parameters and obtain the token value through the Beanshell sampler in the JMeter tool; Set the obtained token value as a global variable for subsequent API calls.

4. A WeChat Mini Program automatic login device based on JMeter, characterized in that, include: The path acquisition unit is used to obtain the project path of the WeChat Mini Program based on the APP ID provided by WeChat using the JMeter tool. The credential data acquisition unit is used to launch the WeChat Developer Tools, call the wx.login() method to obtain a temporary login credential, and determine whether the temporary login credential corresponds to the WeChat Mini Program. The token data acquisition unit is used to call the temporary login credential to obtain a token value using the login interface of the WeChat mini program if the temporary login credential corresponds to the WeChat mini program, and set the token value as a global variable. The script execution unit is used to pass the token value into the request header information of subsequent interfaces of the JMeter tool and execute the JMeter full-link script at regular intervals.

5. A storage medium, characterized in that, The storage medium stores multiple instructions, which are adapted for a processor to load and execute the steps in the JMeter-based automatic login method for WeChat mini-programs as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • WeChat applet automatic login method and storage equipment

    CN110362986A