Method and system for automatically completing code scanning payment test in PC game
The method and system for automatically completing QR code payment tests through PC games realizes the efficient use of real mobile payment operations and device resources, solves the problem of low testing efficiency in existing technologies, and improves device resource utilization and test coverage.
Patent Information
- Application Number
- CN202511082548.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-11-18
AI Technical Summary
Existing game payment tests cannot simulate real operations, have low device resource utilization, and low testing efficiency, especially in multi-device concurrent scenarios where there is a lack of a unified device scheduling and task allocation mechanism.
The method and system for automatically completing QR code payment tests using PC games are presented. Through QR code generation, device scheduling, and payment modules, real mobile payment operations are achieved, and device resources are dynamically allocated in conjunction with device status management.
It improved the utilization rate of equipment resources, increased testing efficiency, solved the problem of incomplete coverage in simulated payment testing, and avoided payment interruptions caused by network jitter.
Smart Images

Figure CN120973675A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of game testing, in particular to a method and system for automatically completing scan code payment testing of PC games. BACKGROUND
[0002] Current game payment testing mainly relies on manual operation or single device simulation, which has significant defects. Although existing automated testing tools can simulate payment processes, they cannot operate mobile payment applications (such as Alipay scan code) in a real way, resulting in incomplete test coverage. Some solutions use fixed devices for real machine testing, but have problems such as low device resource utilization and inability to dynamically allocate devices. Especially in the scenario of concurrent testing of multiple devices, existing technologies lack a unified device scheduling and task allocation mechanism, resulting in low testing efficiency. SUMMARY
[0003] To overcome the problems of game payment testing in the prior art, such as the inability to simulate real operation, low device resource utilization, and low testing efficiency, the purpose of the present application is to provide a method and system for automatically completing scan code payment testing of PC games, which can simulate real mobile payment operations, has high device resource utilization, and has high testing efficiency.
[0004] The present application adopts the following scheme to achieve:
[0005] A method for automatically completing scan code payment testing of PC games, the method steps are as follows:
[0006] Step 1: Start the game client, locate the mall entrance and click on the target product, intercept the payment popup window to generate a unique tracking ID and a two-dimensional code picture;
[0007] Step 2: After the server receives the two-dimensional code picture, it randomly selects an idle device from the Redis device pool and pushes the picture to the device's album;
[0008] Step 3: Control the selected device to start the payment application, access the album and scan the latest two-dimensional code, and complete the payment confirmation operation;
[0009] Step 4: The client polls to detect the payment result, and if the payment is successful, it closes the popup window and cleans up the data, and if the payment times out, it triggers an alarm.
[0010] Further, step 1 is specifically:
[0011] Start the game client, initialize the test environment through the Airtest script, specify the game process name and set the resolution compatibility mode;
[0012] Navigate to the mall interface, locate and click the mall entry button through image recognition, locate the target product after the mall loads and perform a click to trigger the purchase operation, detect whether a payment popup window appears by detecting the dependent control through the popup window, and when the payment popup window appears, capture the full screen to generate a PNG format two-dimensional code picture and generate a unique tracking ID; if the timeout is exceeded, retry clicking.
[0013] Further, step 2 is specifically: the Airtest script uploads the two-dimensional code screenshot picture to the server intermediate interface through the HTTP POST request, and the unique tracking ID and metadata are attached during transmission. The server saves the data to the local after verifying the format, and then queries the Redis device pool, randomly selects a device in an idle state, and pushes the two-dimensional code picture to the selected device's album through encapsulated adb commands. The selected device is locked in the "busy" state.
[0014] Further, step 3 is specifically: the mobile end scan code payment server controls the device to start the payment software through adb commands, identifies the scan code icon of the payment software and performs a click command;
[0015] Access the album command of the device, select the latest picture and click. After the payment software recognizes the two-dimensional code picture, it locates and clicks the "Confirm Payment" button through image matching, and releases the device state as "idle" after completion.
[0016] Further, step 4 is specifically: the game client starts an independent thread to detect the payment result, sets a time interval in a polling mechanism, intermittently scans UI elements, and the scanning of UI elements is achieved by detecting specific text or based on image matching. If the elements are detected within the preset time limit, the payment popup window is automatically closed, test logs are recorded to a file, temporary pictures and session data are cleared; if the timeout is not detected successfully, an alarm is triggered: log failure is marked, a notification is sent, and the test is reinitialized.
[0017] A system for automatically completing scan code payment testing of PC games, the system comprising: a two-dimensional code generation module, a device scheduling module, a payment module, and a detection module;
[0018] The two-dimensional code generation module is configured to start a game client, locate a mall entry and click a target product, and capture a payment popup window to generate a unique tracking ID and a two-dimensional code picture;
[0019] The device scheduling module is configured to randomly select an idle device from a Redis device pool and push the picture to the album of the device after the server receives the two-dimensional code picture;
[0020] The payment module is configured to control the selected device to start a payment application, access the album and scan the latest two-dimensional code, and complete the payment confirmation operation;
[0021] The detection module is used for client polling to detect a payment result, and if the payment is successful, the pop-up window is closed and data is cleaned, and if the payment is timed out, an alarm is triggered.
[0022] Further, the two-dimensional code generation module specifically comprises: starting a game client, initializing a test environment through an Airtest script, specifying a game process name and setting a resolution compatible mode.
[0023] Navigating to a mall interface, an entrance button of the mall is positioned and recognized through image recognition, and a click is performed, a target commodity is positioned and recognized after the mall is loaded, and a click is performed, a purchase operation is triggered, a payment pop-up window is detected through a pop-up window detection dependent control, a full-screen PNG format two-dimensional code picture is intercepted when the payment pop-up window appears, and a unique tracking ID is generated, and if the time is exceeded, the click is retried.
[0024] Further, the device scheduling module specifically comprises: the two-dimensional code picture and the device scheduling script are uploaded to a server interface, and the unique tracking ID and metadata are attached, the server saves the data to the local after verifying the format, then queries a Redis device pool, randomly selects a device in an idle state, and pushes the two-dimensional code picture to the album of the selected device through encapsulation of an adb command, and the selected device is locked in a "busy" state.
[0025] Further, the payment module specifically comprises: a mobile terminal code scanning payment server controls a device to start a payment software through an adb command, recognizes a code scanning icon of the payment software and performs a click command;
[0026] An album access command of the device is called, the latest picture is selected and clicked, after the payment software recognizes the two-dimensional code picture, an image matching positioning is performed and a "confirm payment" button is clicked, and after completion, the device state is released as "idle".
[0027] Further, the detection module specifically comprises: a game client starts an independent thread to detect a payment result, a polling mechanism sets a time interval, and UI elements are intermittently scanned, the scanning of the UI elements is realized through detection of specific text or based on image matching, if the elements are detected within a preset time limit, the payment pop-up window is automatically closed, test logs are recorded to a file, and temporary pictures and session data are cleared; if the time is exceeded and the successful elements are not detected, an alarm is triggered: a log is marked as failed, a notification is sent, and reinitialization of the test is attempted.
[0028] The application has the advantages that:
[0029] The application provides a PC game automatic code scanning payment test method and system, improves test device utilization through dynamic device scheduling, realizes cross-platform operation in a real payment environment, solves the problem that the simulation payment test is not fully covered, and effectively avoids payment interruption caused by network jitter through a two-dimensional code transfer mechanism combined with device state management. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 is a flow chart of the method of the present application;
[0031] Figure 2 is a structure block diagram of the system of the present application. DETAILED DESCRIPTION
[0032] The present application will be further described below in conjunction with the accompanying drawings.
[0033] Referring to Figure 1 A method for automatically completing a code scanning payment test of a PC game, the method comprising the following steps:
[0034] Step 1: Start the game client, locate the mall entrance and click on the target product, intercept the payment pop-up window to generate a unique tracking ID and a two-dimensional code picture;
[0035] Step 2: After the server receives the two-dimensional code picture, randomly select an idle device from the Redis device pool, and push the picture to the album of the device;
[0036] Step 3: Control the selected device to start the payment application, access the album and scan the latest two-dimensional code, and complete the payment confirmation operation;
[0037] Step 4: The client polls to detect the payment result, and if the payment is successful, the pop-up window is closed and the data is cleaned, and if the payment is timed out, an alarm is triggered.
[0038] The present application will be further described below in conjunction with a specific embodiment:
[0039] A method for automatically completing a code scanning payment test of a PC game, the method comprising the following steps:
[0040] Step 1: Start the game client, initialize the test environment through the Airtest script, specify the game process name and set the resolution compatibility mode;
[0041] Navigate to the mall interface, locate and click on the mall entrance button through image recognition, detect the target product after the mall is loaded and execute the click, trigger the purchase operation, detect whether the payment pop-up window is popped up through the pop-up window detection dependent control, intercept the full screen to generate a two-dimensional code picture in PNG format when the payment pop-up window appears, and generate a unique tracking ID; if it is timed out, retry clicking.
[0042] For example: Start the game client on the PC side, initialize the test environment by calling auto_setup() through the Airtest script, specify the game process name game_client.exe and set the resolution compatibility mode. After starting the game using start_app(), navigate to the mall interface: locate the "mall" entry button through image recognition, ensure element visibility based on the template matching algorithm (Template("shop_icon.png")), which takes about 300ms. After clicking the button to enter the mall, the script dynamically detects the completion of the product list loading (depends on the wait() function to poll the "Magic Stone Package" text element), locates the target product coordinates (X:520, Y:320) and performs a single click operation. When the payment popup is rendered, Airtest uses the snapshot() function to capture the full screen and save it as a high-resolution PNG file (such as qrcode_PAY_001.png), while generating a unique tracking ID (such as PAY_20240511_001) based on a combination of timestamp and random array. Payment popup detection uses a composite strategy: first detect the UI control ID pay_dialog, if it does not appear within 5 seconds, retry clicking; after success, record the log.
[0043] Step 2: The QR code picture and device scheduling script are uploaded to the server interface, with a unique tracking ID and metadata, the server verifies the format and saves the data to the local, then queries the Redis device pool, randomly selects idle devices, pushes the QR code picture to the selected device's album through encapsulated adb commands, and the selected device is locked in the "busy" state.
[0044] For example: The Airtest script uploads the screenshot picture to the server intermediate interface / api / upload-qr through HTTP POST request, and attaches the tracking ID and metadata (such as resolution, game version) during transmission. The server is implemented in Go language, uses http.MultipartReader() to parse the form, verifies the picture format (limited to PNG / JPG) and stores it in the temporary directory / tmp / qr_images / PAY_001.png. The server queries the Redis device status pool (key name device_status) to get the status of 10 payment devices (DEV_01 to DEV_10) ("idle" or "busy") in real time, and only selects idle devices. Device selection is based on a random algorithm: after selecting a device within the range of idle devices, the state is locked (redisClient.Set(ctx,"DEV_03","busy",time.Hour)). Go code encapsulates adb commands to transmit pictures:
[0045]
[0046]
[0047] If the transmission fails (such as adb timeout), the server starts the retry mechanism (maximum 3 times) to try another device; after success, the device ID is returned to the script. In the example, for the PAY_001 payment request, the server selects DEV_03 to perform automatic payment, executes the adb push operation, and pushes the two-dimensional code of the to-be-paid goods to the device album.
[0048] Step 3: The mobile terminal scan code payment server controls the device to start the payment software through the adb command, identifies the scan code icon of the payment software, and executes the click command.
[0049] The album access command of the device is called, the latest picture is selected and clicked, after the payment software recognizes the two-dimensional code picture, it is positioned and clicked through image matching "Confirm Payment" button, and after completion, the device state is released as "idle".
[0050] For example: the server controls the selected device to complete the payment operation through the ADB command chain: start the Alipay application (adb-sDEV_03 shell am start-n com.eg.android.AlipayGphone / .AlipayLogin), locate the "Scan" entry button through image recognition, and ensure the element is visible based on the template matching algorithm (Template("alipay_scan_icon.png")). If not found, simulate clicking through coordinates (X:200, Y:1800). The script then triggers the album access: open the album using adb shell input keyevent KEYCODE_GALLERY, select the latest picture based on the file timestamp in descending order (adb shell ls-t / sdcard / Pictures / |head-1) and click. After recognizing the two-dimensional code, Alipay automatically calls the payment page; locate the "Confirm Payment" button through image recognition, and ensure the element appears based on the template matching algorithm (Template("alipay_scan_ok_icon.png")). The entire process adds timeout control (all operations must be completed within 10 seconds). After the script execution is completed, the server releases the occupation state of the payment device, and calls redisClient.Set(ctx,"DEV_03","idle",time.Hour)
[0051] Step 4: The game client starts an independent thread to detect the payment result, a polling mechanism sets a time interval, and an intermittent scanning of UI elements is performed, the scanning of UI elements is achieved by detecting specific text or based on image matching, if the elements are detected within the preset time limit, the payment pop-up window is automatically closed, test logs are recorded to a file, and temporary pictures and session data are cleared; if the timeout does not detect a successful element, an alarm is triggered: log failure is marked, a notification is sent, and the test is reinitialized.
[0052] For example: the game client starts an independent thread to detect the payment result: a polling mechanism scans UI elements every 500 ms, specific text (such as "Magic Stone Recharge Success") is detected using Airtest's poco (textContains="Payment Success").exists(), or based on image matching (wait (Template ("success_banner.png"))). If the elements are detected within the set time limit (15 seconds), the payment pop-up window is automatically closed (keyevent ("KEYCODE_BACK") is called), and test logs are recorded to a file (such as pay_LOG_001.txt). If the timeout does not detect a successful element (such as due to network delay), the system triggers an alarm: log failure is marked, a notification is sent, and the test is reinitialized; after the payment is completed, temporary pictures and session data are cleared.
[0053] Referring to Figure 2 A system for automatically completing a code scanning payment test of a PC game, the system comprising: a two-dimensional code generation module, a device scheduling module, a payment module, and a detection module;
[0054] The two-dimensional code generation module is configured to start a game client, locate a mall entrance and click on a target product, and intercept a payment pop-up window to generate a unique tracking ID and a two-dimensional code picture;
[0055] The device scheduling module is configured to randomly select an idle device from a Redis device pool after the server receives the two-dimensional code picture, and push the picture to the album of the device;
[0056] The payment module is configured to control the selected device to start a payment application, access the album, and scan the latest two-dimensional code to complete a payment confirmation operation;
[0057] The detection module is configured to poll the client to detect the payment result, close the pop-up window and clean up the data if the payment is successful, and trigger an alarm if the payment times out.
[0058] In an embodiment of the present application, the two-dimensional code generation module specifically comprises: starting a game client, initializing a test environment through an Airtest script, specifying a game process name and setting a resolution compatibility mode;
[0059] Navigate to the mall interface, locate and click the mall entrance button through image recognition, locate the target commodity after the mall is loaded and execute the click, trigger the purchase operation, detect whether the payment popup window is popped up through the popup window detection dependent control, when the payment popup window appears, intercept the full screen to generate a PNG format two-dimensional code picture, and generate a unique tracking ID; if timeout, retry clicking.
[0060] In an embodiment of the application, the device scheduling module is specifically: the two-dimensional code picture and the device scheduling script are uploaded to the server interface, with the unique tracking ID and metadata, the server saves the data to the local after verifying the format, then queries the Redis device pool, randomly selects the device in the idle state, and pushes the two-dimensional code picture to the album of the selected device through encapsulating the adb command, and the selected device is locked in the state of "busy".
[0061] The template matching algorithm in the application is the prior art in the art, for example, the Template("alipay_scan_ok_icon.png") mentioned in the embodiment is a function command provided by the airtest framework, which is used to match the similarity of shop_icon.png.
[0062] In an embodiment of the application, the payment module is specifically: the mobile end scan code payment server controls the device to start the payment software through the adb command, recognizes the scan code icon of the payment software and executes the click command;
[0063] The album access command of the device is called, the latest picture is selected and clicked, after the payment software recognizes the two-dimensional code picture, the "confirm payment" button is located and clicked through image matching, and the device state is released as "idle" after completion.
[0064] In an embodiment of the application, the detection module is specifically: the game client starts an independent thread to detect the payment result, a polling mechanism is set to set the time interval, and the UI elements are intermittently scanned, the scanning of the UI elements is realized by detecting specific text or based on image matching, if the elements are detected within the preset time limit, the payment popup window is automatically closed, the test log is recorded to the file, the temporary picture and session data are cleared; if the successful elements are not detected within the timeout, an alarm is triggered: the log is marked as failed, a notification is sent, and the test is reinitialized.
[0065] The above only describes the preferred embodiments of the application, and any changes and modifications made within the scope of the application should be included in the scope of the application.
Claims
1. A method for automatically completing QR code payment testing in PC games, characterized in that, The method steps are as follows: Step 1: Launch the game client, locate the store entrance and click on the target product, capture the payment pop-up to generate a unique tracking ID and QR code image; Step 2: After receiving the QR code image, the server randomly selects an idle device from the Redis device pool and pushes the image to the device's photo album; Step 3: Control the selected device to launch the payment application, access the photo album and scan the latest QR code to complete the payment confirmation operation; Step 4: The client polls to check the payment result. If the payment is successful, the pop-up window is closed and the data is cleared. If the payment times out, an alarm is triggered.
2. The method for automatically completing QR code payment testing in PC games according to claim 1, characterized in that, Step 1 is as follows: Launch the game client, initialize the test environment using the Airtest script, specify the game process name, and set the resolution compatibility mode; Navigate to the online store interface, use image recognition to locate and click the store entry button, detect when the store loads, locate the target product and click it to trigger a purchase. Use pop-up detection to check if a payment pop-up will appear. When the payment pop-up appears, capture the full screen to generate a PNG QR code image and generate a unique tracking ID; if a timeout occurs, retry clicking.
3. The method for automatically completing QR code payment testing in PC games according to claim 2, characterized in that, Step 2 is as follows: The Airtest script uploads a screenshot of the QR code to the server's relay interface via an HTTP POST request, attaching a unique tracking ID and metadata during transmission. After the server verifies the format, it saves the data locally. Then, it queries the Redis device pool, randomly selects devices in an idle state, and pushes the QR code image to the album of the selected device through a wrapped adb command. The selected device is locked in a "busy" state.
4. The method for automatically completing QR code payment testing in PC games according to claim 1, characterized in that, Step 3 specifically involves: The mobile payment server controlling the device to launch the payment software via ADB commands, recognizing the payment software's QR code icon, and executing the click command; The device's photo album access command is invoked, the latest picture is selected and clicked, the payment software recognizes the QR code image, locates it through image matching and clicks the "Confirm Payment" button, and the device is released to "idle" status after completion.
5. The method for automatically completing QR code payment testing in PC games according to claim 1, characterized in that, Step 4 specifically involves: the game client starting an independent thread to detect payment results, using a polling mechanism to set time intervals and intermittently scanning UI elements. The scanning of UI elements is achieved by detecting specific text or based on image matching. If an element is detected within a preset time limit, the payment pop-up is automatically closed, the test log is recorded to a file, and temporary images and session data are cleared. If no successful element is detected within the time limit, an alarm is triggered: the log is marked as failed, a notification is sent, and an attempt is made to reinitialize the test.
6. A system for automatically completing QR code payment testing in PC games, characterized in that, The system includes: a QR code generation module, a device scheduling module, a payment module, and a detection module; The QR code generation module is used to launch the game client, locate the mall entrance and click on the target product, capture the payment pop-up window and generate a unique tracking ID and QR code image; The device scheduling module is used to randomly select an idle device from the Redis device pool after the server receives the QR code image, and push the image to the device's album. The payment module is used to control the selected device to launch the payment application, access the photo album and scan the latest QR code to complete the payment confirmation operation; The detection module is used by the client to poll and detect payment results. If the payment is successful, the pop-up window is closed and the data is cleared. If the payment times out, an alarm is triggered.
7. The system for automatically completing QR code payment testing in PC games according to claim 6, characterized in that, The QR code generation module works as follows: it starts the game client, initializes the test environment through the Airtest script, specifies the game process name, and sets the resolution compatibility mode. Navigate to the online store interface, use image recognition to locate and click the store entry button, detect when the store loads, locate the target product and click it to trigger a purchase. Use pop-up detection to check if a payment pop-up will appear. When the payment pop-up appears, capture the full screen to generate a PNG QR code image and generate a unique tracking ID; if a timeout occurs, retry clicking.
8. The system for automatically completing QR code payment testing in PC games according to claim 6, characterized in that, The device scheduling module specifically works as follows: QR code images and device scheduling scripts are uploaded to the server interface, along with a unique tracking ID and metadata. After the server verifies the format, it saves the data locally. Then, it queries the Redis device pool, randomly selects devices in an idle state, and pushes the QR code image to the album of the selected device through encapsulated adb commands. The selected device is locked in a "busy" state.
9. A system for automatically completing QR code payment testing in PC games according to claim 6, characterized in that, The payment module specifically consists of: the mobile QR code payment server controlling the device to launch the payment software via ADB commands, recognizing the QR code icon of the payment software, and executing the click command; The device's photo album access command is invoked, the latest picture is selected and clicked, the payment software recognizes the QR code image, locates it through image matching and clicks the "Confirm Payment" button, and the device is released to "idle" status after completion.
10. A system for automatically completing QR code payment testing in PC games according to claim 6, characterized in that, The detection module works as follows: The game client starts an independent thread to detect payment results. A polling mechanism is used to set time intervals and intermittently scan UI elements. The scanning of UI elements is achieved by detecting specific text or based on image matching. If an element is detected within a preset time limit, the payment pop-up window is automatically closed, the test log is recorded to a file, and temporary images and session data are cleared. If no successful element is detected within the time limit, an alarm is triggered: the log is marked as failed, a notification is sent, and an attempt is made to reinitialize the test.