An automated testing method, apparatus, device, and storage medium
Patent Information
- Application Number
- CN202311799563.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-12-25
AI Technical Summary
[0005]本申请提供一种自动化测试方法、装置、设备以及存储介质,用以解决用户界面自动化测试脚本开发成本高、维护成本高、测试环境复杂且部署成本高的问题
Smart Images

Figure CN117762802B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an automated testing method, apparatus, device, and storage medium. Background Technology
[0002] UI (User Interface) automated testing is a testing method that simulates real user operations based on page graphics. It aims to check whether user interface programs can interact normally and whether there are any defects that hinder user behavior. By using UI automated testing, users can check the software's performance on different platforms, browsers, and devices, ensuring that it functions correctly in various environments.
[0003] Currently, UI automation testing typically involves writing test scripts to execute the required tests when needed, simulating user actions in an application or website, such as clicking buttons, entering text, and validating page elements.
[0004] However, performing automated UI testing by writing test scripts when needed involves a lot of repetitive work. Different systems require different test frameworks and test scripts, and testers need to spend a lot of time maintaining the test scripts they write. Furthermore, UI automation testing is limited by various test environments. Performing automated UI testing by writing test scripts requires a lot of time and effort to configure the test environment and simulate scenarios under different browsers and versions, which reduces the efficiency of UI automation testing. Summary of the Invention
[0005] This application provides an automated testing method, apparatus, device, and storage medium to solve the problems of high development cost, high maintenance cost, complex testing environment, and high deployment cost of user interface automated test scripts.
[0006] Firstly, this application provides an automated testing method, comprising:
[0007] In response to operations on the automated testing platform, obtain the identifier of the target test case;
[0008] Based on the preset correspondence and the identifier of the target test case, the target data in the target test case database table is retrieved. The correspondence represents the correspondence between the identifier of the test case and the data in the target test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table.
[0009] Based on the target data, construct the target test case script;
[0010] Based on the target test case script, obtain the user interface automated test report.
[0011] In this embodiment of the application, before retrieving target data from the target database table based on the preset correspondence and the identifier of the target test case, the method further includes:
[0012] In response to the user's operation of adding test cases to the automated testing platform, the new test case data is obtained. The new test case data includes the data added to the keyword database table, element database table, test case step database table, and test case information database table.
[0013] Save the newly added test case data to the corresponding test case database table.
[0014] In this embodiment, the automated testing platform displays a test case management interface, a keyword management interface, and an element management interface. The test case management interface includes a test case step name input area, an element selection area, and a keyword selection area. In response to the user's operation of adding a test case to the automated testing platform, the platform obtains new test case data, including:
[0015] In response to the user's input operation in the test case step name input area of the test case management interface, the name and parameter value data of each step of the newly added test case are obtained;
[0016] In response to the user's selection operation in the element selection area of the test case management interface, the element data of the newly added test case is obtained;
[0017] In response to the user's selection operation in the keyword selection area of the test case management interface, the keyword data of the new test case is obtained;
[0018] Based on the keyword management interface and the element management interface, display keywords and manage the elements of the test page;
[0019] Based on the name, parameter value data, element data, keyword data, and browser version data of each step of the newly added test case, the new test case data and test case data identifier are obtained.
[0020] In embodiments of this application, the method further includes:
[0021] When there are more than two new test case data entries, the new test case data is processed by a collection, and the processed new test case data is saved to the corresponding test case database table.
[0022] In this embodiment of the application, target data is retrieved from the target test case database table according to a preset correspondence and the identifier of the target test case, including:
[0023] Based on the correspondence and the identifier of the target test case, determine the test case step information and browser information corresponding to the identifier of the target test case. The test case step information includes the element identifier and keyword identifier of the target test case.
[0024] Based on the element identifier and keyword identifier of the target test case, determine the element information and keyword information corresponding to the element identifier and keyword identifier of the target test case from the target test case database table;
[0025] Determine the browser version corresponding to the target test case based on the browser information.
[0026] In this embodiment of the application, an automated user interface test report is obtained based on the target test case script, including:
[0027] Identify the target automated testing tool and the control commands sent by the remote browser driver;
[0028] Based on the control commands sent by the target automated testing tool and the remote browser driver, the target browser is launched, where the version of the target browser corresponds to the browser version information in the target test case script;
[0029] Based on the target browser, execute the target test cases and obtain an automated test report of the user interface.
[0030] In this embodiment of the application, the target browser is launched according to the control instructions sent by the target automated testing tool and the remote browser driver, including:
[0031] Obtain the browser version information from the target test case script;
[0032] Based on the browser version information in the target test case script, obtain the Docker image of the target browser, where the Docker image of the target browser corresponds to the browser version information in the target test case script;
[0033] Start the Docker image container based on the Docker image of the target browser;
[0034] Launch the target browser from the Docker image container.
[0035] In this embodiment of the application, target test cases are executed based on the target browser to obtain an automated user interface test report, including:
[0036] Determine the browser driver for the target browser and the output directory for the test report;
[0037] Run automated testing tools based on the target browser's browser driver;
[0038] Based on the automated testing tools after they have run, the target test cases are executed to obtain the user interface automated test report;
[0039] Copy the user interface automation test report to the output directory of the test report.
[0040] In this embodiment of the application, the method further includes:
[0041] Obtain the screen recording requirements, log requirements, and target directory for the target test case;
[0042] Based on the screen recording and logging requirements of the target test cases, obtain the video files and log files of the target test cases;
[0043] Copy the video files and log files to the target directory.
[0044] Secondly, this application provides an automated testing apparatus, comprising:
[0045] The acquisition module is used to obtain the identifier of the target test case in response to operations on the automated testing platform;
[0046] The retrieval module is used to retrieve target data from the target test case database table according to the preset correspondence and the identifier of the target test case. The correspondence represents the correspondence between the identifier of the test case and the data in the test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table.
[0047] The build module is used to construct target test case scripts based on the target data;
[0048] The determination module is used to generate an automated test report for the user interface based on the target test case script.
[0049] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0050] The memory stores instructions that the computer executes;
[0051] The processor executes computer execution instructions stored in memory to implement the automated testing method of this application embodiment.
[0052] Fourthly, a computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the automated testing method of the embodiments of this application.
[0053] This application provides an automated testing method, apparatus, device, and storage medium. By obtaining the identifiers of target test cases and the correspondence between preset test case identifiers and data in a test case database table, the method retrieves target data from the target test case database table. The target test case database table includes keyword database sub-tables, element database sub-tables, test case step database sub-tables, and test case information database sub-tables. Based on the target data, a target test case script is constructed, and a user interface automated test report is obtained from the target test case script. The UI automated testing method provided by this application reduces the time and workload of manually executing the same test steps repeatedly, lowers the maintenance cost of user interface automated testing, and improves the efficiency of user interface automated testing. Attached Figure Description
[0054] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0055] Figure 1 A flowchart illustrating an automated testing method provided in an embodiment of this application;
[0056] Figure 2 This is a schematic diagram illustrating the effect of an automated testing method provided in an embodiment of this application;
[0057] Figure 3 A flowchart illustrating another automated testing method provided in an embodiment of this application;
[0058] Figure 4 This is a schematic diagram of the structure of the automated testing device provided in the embodiments of this application;
[0059] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0060] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0061] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0062] In existing technologies, UI automation testing generally involves writing test scripts to execute the required tests when needed. Different test frameworks and test scripts need to be developed for different systems, requiring repeated writing of test scripts. Testers need to spend a lot of time maintaining the written test scripts. Furthermore, UI automation testing is limited by various test environments. Executing automated tests of the user interface through written test scripts requires a lot of time and effort to configure the test environment and simulate scenarios under different browsers and versions, which reduces the efficiency of UI automation testing.
[0063] This application can retrieve target data from a target test case database table by obtaining the identifiers of the target test cases and the correspondence between the identifiers of the preset test cases and the data in the test case database table. The target test case database table includes keyword database sub-tables, element database sub-tables, test case step database sub-tables, and test case information database sub-tables. Based on the target data, a target test case script is constructed, and a user interface automated test report is obtained from the target test case script. The automated testing method provided by this application saves the keyword data, element data, test case step data, and test case information data of the test cases to a data table through an automated testing platform, and constructs repeatable test cases through the data table. This reduces the time and workload of manually executing the same test steps repeatedly, and lowers the maintenance cost of user interface automated testing. Furthermore, the automated testing method provided by this application improves the efficiency of user interface automated testing by selecting and executing the corresponding test cases on the testing platform, without repeatedly writing and executing the same test steps.
[0064] This application provides an automated testing method. The executing entity of this automated testing method can be a server, which can provide an automated testing environment and resources, allowing testers to run and manage test scripts on the server. This embodiment does not impose any particular restrictions on the implementation method of the executing entity, as long as the executing entity can respond to operations on the automated testing platform, obtain the identifier of the target test case; retrieve target data from the target test case database table according to a preset correspondence and the identifier of the target test case, wherein the correspondence represents the correspondence between the identifier of the test case and the data in the test case database table, and the target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table; construct the target test case script based on the target data; and obtain the user interface automated test report based on the target test case script.
[0065] Figure 1 This is a flowchart illustrating an automated testing method provided in an embodiment of this application. Figure 1As shown, this method may include:
[0066] S101. In response to an operation on the automated testing platform, obtain the identifier of the target test case.
[0067] An automated testing platform can be a comprehensive tool or system for managing and executing automated tests. It provides a range of functions and tools to help testing teams plan, execute, manage, and monitor automated tests. An automated testing platform may include test case management, keyword management, element management, and task management modules. It provides the ability to write and edit test scripts, configure and manage different testing environments, including operating systems, browsers, and devices, to facilitate the execution of test scripts. Furthermore, the automated testing platform can generate detailed test results and reports, including test coverage, error logs, screenshots, etc., to help testers analyze and evaluate test results.
[0068] A target test case can be a set of test steps that need to be executed automatically to verify whether the software under test can perform as expected. For example, target test cases can be UI test cases, login verification test cases, form verification test cases, or database test cases.
[0069] In this embodiment of the application, when a user clicks to execute a test case on the automated testing platform, the user can obtain the list of test cases and identifiers contained in the test suite by querying the corresponding test suite in the testing platform. It should be noted that the test suite can represent the combination rules of test cases.
[0070] S102. Based on the preset correspondence and the identifier of the target test case, retrieve the target data from the target test case database table. The correspondence represents the correspondence between the identifier of the test case and the data in the target test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table.
[0071] The target test case database table can be a data table used to store target test case information in a software development project. In this embodiment, the target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table. The keyword database sub-table refers to a data table used to define keywords used in test cases, store keywords and their corresponding operations. It should be noted that keywords can refer to predefined operations or steps used to complete specific tasks in UI test cases, such as clicking a button, entering text, or waiting for a page to load. Keywords are usually defined by relevant testing frameworks or libraries and can be used individually or in combination to build more complex test cases and reduce the amount of test code. The keyword database sub-table can include a unique identifier for each keyword in the sub-table; the name or description of the keyword, such as clicking, entering text, or waiting for a page to load; and the actual test operation corresponding to the keyword, such as simulating clicking a button or entering text. Testers can encapsulate and combine these keywords to build more complex test cases to verify the correctness and reliability of the software or application.
[0072] The element database sub-table refers to a data table used to store information about page elements used by automated test scripts, including the element's location method and location value. It's important to note that an element can refer to a page element that requires interaction or state verification during UI testing. These are typically HTML (Hypertext Markup Language) elements in web pages or UI elements in mobile applications. Elements can include buttons, input boxes, dropdown lists, text, labels, etc. The element database sub-table can include a unique identifier for each element, the name or identifier of the page containing the element, the element name, the method of locating the element, and the location value. Testers can use the element's unique identifier to locate and manipulate these elements in test cases. This allows them to update the corresponding element identifiers when the page changes, without needing to modify the entire test case, thus reducing the maintenance cost of test cases.
[0073] The test case step database sub-table can refer to a data table used to store the execution step information of test cases. It can include the name of each step, the element identifier of the operation, the keyword identifier of the operation, and the input data, such as the input text and the waiting time.
[0074] The test case information database sub-table is used to store information about test cases, including the test case identifier, test case name, browser and browser version corresponding to the test case, project module to which the test case belongs, creator, creation time, etc.
[0075] In this embodiment of the application, when a user clicks to execute a test case on the automated testing platform, the target data such as keyword data, element data, test case step data, and test case information data stored in the keyword database sub-table, element database sub-table, test case step database sub-table, and test case information database sub-table in the test case database table can be retrieved according to the preset correspondence and the identifier of the target test case obtained in step S101.
[0076] In this embodiment of the application, retrieving target data from the target test case database table based on a preset correspondence and the identifier of the target test case may include:
[0077] Based on the correspondence and the identifier of the target test case, determine the test case step information and browser information corresponding to the identifier of the target test case. The test case step information includes the element identifier and keyword identifier of the target test case.
[0078] Based on the element identifier and keyword identifier of the target test case, determine the element information and keyword information corresponding to the element identifier and keyword identifier of the target test case from the target test case database table;
[0079] Determine the browser version corresponding to the target test case based on the browser information.
[0080] In this application, the step information corresponding to the identifier of the target test case can be determined through a preset correspondence and the identifier of the target test case. A search is then performed in the target test case database table to find the element information and keyword information corresponding to the element identifier and keyword identifier. Based on the retrieved element information and keyword information, further processing is performed, such as executing the operation corresponding to the keyword or obtaining the element's attributes. Simultaneously, this embodiment can also use a preset correspondence and the identifier of the target test case to search in the test case information database table to determine the browser information corresponding to the identifier of the target test case, thereby determining the browser to be used. It should be noted that the browser information includes browser version, browser type, etc.
[0081] In this embodiment of the application, obtaining the user interface automated test report based on the target test case script may include:
[0082] Identify the target automated testing tool and the control commands sent by the remote browser driver;
[0083] Based on the control commands sent by the target automated testing tool and the remote browser driver, the target browser is launched, where the version of the target browser corresponds to the browser version information in the target test case script;
[0084] Based on the target browser, execute the target test cases and obtain an automated test report of the user interface.
[0085] Target automated testing tools are used to automate the testing of software functionality during the software development process, enabling the rapid and accurate discovery and fixing of code errors and issues. Commonly used automated testing tools include Selenium (Selenium WebDriver), Appium (Appium Mobile Automation Framework), JMeter (Apache JMeter), and Robot Framework. In this embodiment, the target automated testing tool can be Selenoid (Selenoid Selenium Hub in Docker). It should be noted that Selenoid is an open-source, lightweight Selenium test container manager that provides a Docker-based containerized Selenium Grid, which can launch multiple instances of different browsers and run automated tests on these instances. Selenoid also provides several practical features, such as browser logging, video recording, and WebRTC support, which help developers more easily develop and debug automated test cases.
[0086] Remote WebDriver refers to a method of sending web application test code and WebDriver commands to a browser on a remote computer for execution. By using Remote WebDriver, test code can be sent to a remote computer for execution, thereby enabling automated testing of remote browsers.
[0087] In this embodiment, the server can send instructions to selenoid via Remote WebDriver, thereby enabling selenoid to connect to the target browser, send test instructions to the target browser, execute target test cases, and generate an automated user interface test report.
[0088] In this embodiment of the application, launching the target browser based on the control commands sent by the target automated testing tool and the remote browser driver may include:
[0089] Obtain the browser version information from the target test case script;
[0090] Based on the browser version information in the target test case script, obtain the Docker image of the target browser, where the Docker image of the target browser corresponds to the browser version information in the target test case script;
[0091] Start the Docker image container based on the Docker image of the target browser;
[0092] Launch the target browser from the Docker image container.
[0093] A Docker image can be a lightweight, executable software package that contains everything needed to run a Docker container, including application code, system tools, library files, environment variables, and configuration files, and can be used to create runtime instances of Docker containers.
[0094] Docker image containers are lightweight, portable containers that can package applications or their dependencies, libraries, and configuration files as a single unit and run them anywhere a Docker environment is supported. Docker image containers can isolate resources such as the operating system and applications, allowing applications to run within their own containers without interference. By using Docker image containers, developers can package applications and infrastructure into a fixed container format, enabling cross-platform application deployment and operation.
[0095] In this embodiment, please refer to Figure 2 , Figure 2 This illustration shows the effect of an automated testing method provided in this application. After constructing the target test case script using an automated testing platform and a target test case database, the browser version information in the target test case script can be obtained by parsing the parameters in the statement that opens the browser in the script. Based on the browser version information, the required Docker image for running the target test case script is searched in the image repository. Then, a remote WebDriver provided by the Docker image container is connected via the WebDriver client library, and the target browser in the Docker image container is started. Furthermore, if multiple test cases are executed simultaneously, and each test case requires a different browser version, the Docker image container can be automatically invoked via Selenoid to achieve independent testing environments for multiple different browser versions.
[0096] In this embodiment of the application, executing target test cases based on the target browser to obtain a user interface automated test report may include:
[0097] Determine the browser driver for the target browser and the output directory for the test report;
[0098] Run automated testing tools based on the target browser's browser driver;
[0099] Based on the automated testing tools after they have run, the target test cases are executed to obtain the user interface automated test report;
[0100] Copy the user interface automation test report to the output directory of the test report.
[0101] The output directory for browser drivers and test reports can be configured according to specific circumstances.
[0102] A browser driver can be middleware that connects a testing framework to a browser. It acts as a bridge between the testing framework and the browser, helping the testing framework communicate and interact with the specific browser. The browser driver can control the browser's behavior, execute user-defined test operations, and obtain test results.
[0103] In this embodiment, the appropriate browser driver can be determined based on the type of the target browser. For example, ChromeDriver can be used for Chrome, GeckoDriver for Firefox, and SafariDriver for Safari. After obtaining the driver, it can be placed in the system path or the driver path can be specified in the test script. Using the selected browser driver, combined with the corresponding automated testing tool (such as Selenium WebDriver), automated tests are executed. The target test cases are executed through the automated testing tool, the automated test process is run, user interface operations are performed, and the results are verified. The generated user interface automated test report is then copied to the configured test report output directory for subsequent analysis, viewing, and sharing.
[0104] In this embodiment of the application, executing the target test cases according to the automated testing tool after it has run further includes:
[0105] Obtain the screen recording requirements, log requirements, and target directory for the target test case;
[0106] Based on the screen recording and logging requirements of the target test cases, obtain the video files and log files of the target test cases;
[0107] Copy the video files and log files to the target directory.
[0108] The target directory can be a directory used to store video files and log files.
[0109] In this embodiment, automated testing tools, such as Selenium WebDriver, are used to execute automated tests, which can meet the screen recording and logging requirements of the target test cases. Specifically, based on the determined screen recording or logging requirements, configuration parameters for the automated testing tools or other screen recording and logging-related tools are set. These configuration parameters may include screen recording resolution, recording frame rate, log level, and format, etc. After the test execution is completed, the screen recording and log files are obtained according to the configuration of the tools used, and the obtained video files and log files are copied to a predetermined target directory.
[0110] S103. Based on the target data, construct the target test case script.
[0111] Test case scripts refer to programming scripts used to execute automated tests. They describe test steps, expected results, and verification logic. They are usually written based on test frameworks and programming languages. By writing test case scripts, large-scale test automation can be achieved, improving the efficiency and accuracy of testing.
[0112] In this embodiment, a test case script structure can be designed using a testing framework, programming language (such as Selenium WebDriver, RobotFramework, JUnit, Python, etc.), and target data. This includes importing necessary libraries, initializing the test environment, and defining test case functions. Based on the test steps and parameter data in the target data, corresponding test case functions are written to use the test framework's application programming interface to call the browser, locate elements, perform operations, and verify the expected results.
[0113] S104. Based on the target test case script, obtain the user interface automated test report.
[0114] In this embodiment of the application, after constructing the target test case script, the target test case script can be executed by running the execution command of the test framework or calling the corresponding application interface, and a test report can be generated or the test results can be recorded.
[0115] By obtaining the identifiers of the target test cases and the correspondence between the preset test case identifiers and the data in the test case database table, the target data in the target test case database table is retrieved. This target test case database table includes keyword database sub-tables, element database sub-tables, test case step database sub-tables, and test case information database sub-tables. Based on the target data, target test case scripts are constructed, and a user interface automated test report is obtained from these scripts. The automated testing method provided in this application saves the keyword data, element data, test case step data, and test case information data of test cases to a data table through an automated testing platform. It then constructs repeatable test cases using this data table, reducing the time and workload of manually executing the same test steps repeatedly, and lowering the maintenance cost of user interface automated testing. Furthermore, the automated testing method provided in this application improves the efficiency of user interface automated testing by selecting and executing the corresponding test cases on the testing platform, without needing to repeatedly write and execute the same test steps.
[0116] Figure 3 This is a flowchart illustrating another automated testing method provided in an embodiment of this application. Figure 3 As shown, this method may include:
[0117] S301. In response to the user's operation of adding test cases to the automated testing platform, the new test case data is obtained. The new test case data includes the data added to the keyword database table, element database table, test case step database table, and test case information database table.
[0118] In this embodiment, after entering the UI automation testing platform, the user can input the interface elements of the system to be tested, the name of each step of the test case, the interface elements to be operated, the keywords of the operation, the parameter values to be input for each step, and the browser and version to be tested through the UI automation testing platform.
[0119] In this embodiment, the automated testing platform displays a test case management interface, a keyword management interface, and an element management interface. The test case management interface includes a test case step name input area, an element selection area, and a keyword selection area. In response to a user's operation to add a test case to the automated testing platform, the platform obtains new test case data, which may include:
[0120] In response to the user's input operation in the test case step name input area of the test case management interface, the name and parameter value data of each step of the newly added test case are obtained;
[0121] In response to the user's selection operation in the element selection area of the test case management interface, the element data of the newly added test case is obtained;
[0122] In response to the user's selection operation in the keyword selection area of the test case management interface, the keyword data of the new test case is obtained;
[0123] Based on the keyword management interface and the element management interface, display keywords and manage the elements of the test page;
[0124] Based on the name, parameter value data, element data, keyword data, and browser version data of each step of the newly added test case, the new test case data and test case data identifier are obtained.
[0125] In this embodiment, the test case management interface can be an interface of an automated testing platform. The test case management interface can be used to add, modify, and delete test cases. The new test case page displays a test case step name input area, an element selection area, a keyword selection area, and an input value area. Users can enter the name and parameter values of each step in the test case step name input area, select the element data required for the test case in the element selection area, and select the keyword data required for the test case in the keyword selection area. Furthermore, when adding an input box or text area below each step in the test case management interface, users can enter the corresponding value in the input value area. When users select keywords and elements, an input value area will appear next to the selection area, allowing them to enter the corresponding value and associate it with the keyword or element.
[0126] Users can enter the name and parameter values for each step of the test case in the test case step input area. They can add, edit, and delete steps as needed and set the required input parameters for each step. Users can select information about the page elements involved in the test case in the selection area, including the element positioning method and selector. The element positioning method and selector are used to locate and manipulate elements on the page when executing the test case. Users can select keywords used in the test case in the keyword selection area. Based on the name and parameter values of each step of the newly added test case, element data, keyword data, and browser version data, a unique test case data identifier is assigned to the new test case data for subsequent test execution and management.
[0127] S302. Save the newly added test case data to the corresponding test case database table.
[0128] In this embodiment, the data added in step S301 can be correspondingly saved to the keyword database table, element database table, use case step database table, or use case information database table in the database table.
[0129] In this embodiment of the application, saving the newly added test case data to the corresponding test case database table may include:
[0130] When there are more than two new test case data entries, the new test case data is processed by a collection, and the processed new test case data is saved to the corresponding test case database table.
[0131] After adding test case data through the UI automation testing platform and saving the data to the corresponding database table, the various components of the test case can be stored in a structured manner, including keywords, elements, test case steps, and test case information. The test case data table allows for easy querying, editing, and deletion of test cases and their components, improving test case reusability and reducing repetitive work during testing.
[0132] Figure 4 This is a schematic diagram of the structure of the automated testing device provided in an embodiment of this application. Figure 4 As shown, the automated testing device 40 includes: an acquisition module 401, a retrieval module 402, a construction module 403, and a determination module 404. Wherein:
[0133] Module 401 retrieves the identifier of the target test case in response to operations on the automated testing platform;
[0134] The retrieval module 402 is used to retrieve target data from the target test case database table according to the preset correspondence and the identifier of the target test case. The correspondence represents the correspondence between the identifier of the test case and the data in the target test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table.
[0135] Module 403 is used to build target test case scripts based on target data.
[0136] Module 404 is used to generate an automated test report for the user interface based on the target test case script.
[0137] As can be seen from the above, the automated testing device of this embodiment can retrieve target data from the target test case database table by obtaining the identifier of the target test case and the correspondence between the identifier of the preset test case and the data in the test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table. Based on the target data, a target test case script is constructed, and a user interface automated test report is obtained based on the target test case script. The UI automated testing method provided in this application reduces the time and workload of manually executing the same test steps repeatedly, lowers the maintenance cost of user interface automated testing, and improves the efficiency of user interface automated testing.
[0138] In this embodiment of the application, the acquisition module 401 can also be used for:
[0139] In response to the user's operation of adding test cases to the automated testing platform, the new test case data is obtained. The new test case data includes the data added to the keyword database table, element database table, test case step database table, and test case information database table.
[0140] Save the newly added test case data to the corresponding test case database table.
[0141] In this embodiment, the automated testing platform displays a test case management interface, a keyword management interface, and an element management interface. The test case management interface includes a test case step name input area, an element selection area, and a keyword selection area. The acquisition module 401 can also be used for:
[0142] In response to the user's input operation in the test case step name input area of the test case management interface, the name and parameter value data of each step of the newly added test case are obtained;
[0143] In response to the user's selection operation in the element selection area of the test case management interface, the element data of the newly added test case is obtained;
[0144] In response to the user's selection operation in the keyword selection area of the test case management interface, the keyword data of the new test case is obtained;
[0145] Based on the keyword management interface and the element management interface, display keywords and manage the elements of the test page;
[0146] Based on the name, parameter value data, element data, keyword data, and browser version data of each step of the newly added test case, the new test case data and test case data identifier are obtained.
[0147] In embodiments of this application, the construction module 403 may also be used for:
[0148] When there are more than two new test case data entries, the new test case data is processed by a collection, and the processed new test case data is saved to the corresponding test case database table.
[0149] In embodiments of this application, the determining module 404 may also be used for:
[0150] Based on the correspondence and the identifier of the target test case, determine the test case step information and browser information corresponding to the identifier of the target test case. The test case step information includes the element identifier and keyword identifier of the target test case.
[0151] Based on the element identifier and keyword identifier of the target test case, determine the element information and keyword information corresponding to the element identifier and keyword identifier of the target test case from the target test case database table;
[0152] Determine the browser version corresponding to the target test case based on the browser information.
[0153] In this embodiment of the application, the determining module 404 can also be used for:
[0154] Identify the target automated testing tool and the control commands sent by the remote browser driver;
[0155] Based on the control commands sent by the target automated testing tool and the remote browser driver, the target browser is launched, where the version of the target browser corresponds to the browser version information in the target test case script;
[0156] Based on the target browser, execute the target test cases and obtain an automated test report of the user interface.
[0157] In this embodiment of the application, the acquisition module 401 can also be used for:
[0158] Obtain the browser version information from the target test case script;
[0159] Based on the browser version information in the target test case script, obtain the Docker image of the target browser, where the Docker image of the target browser corresponds to the browser version information in the target test case script;
[0160] Start the Docker image container based on the Docker image of the target browser;
[0161] Launch the target browser from the Docker image container.
[0162] In embodiments of this application, the determining module 304 may also be used for:
[0163] Determine the browser driver for the target browser and the output directory for the test report;
[0164] Run automated testing tools based on the target browser's browser driver;
[0165] Based on the automated testing tools after they have run, the target test cases are executed to obtain the user interface automated test report;
[0166] Copy the user interface automation test report to the output directory of the test report.
[0167] In embodiments of this application, the acquisition module 401 can also be used for:
[0168] Obtain the screen recording requirements, log requirements, and target directory for the target test case;
[0169] Based on the screen recording and logging requirements of the target test cases, obtain the video files and log files of the target test cases;
[0170] Copy the video files and log files to the target directory.
[0171] As can be seen from the above, the embodiments of this application can retrieve target data from the target test case database table by obtaining the identifier of the target test case and the correspondence between the preset test case identifier and the data in the test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table. Based on the target data, a target test case script is constructed, and a user interface automated test report is obtained based on the target test case script. The automated testing method provided by this application saves the keyword data, element data, test case step data, and test case information data of the test cases to a data table through an automated testing platform, and constructs repeatable test cases through the data table. This reduces the time and workload of manually executing the same test steps repeatedly, and lowers the maintenance cost of user interface automated testing. Furthermore, the automated testing method provided by this application improves the efficiency of user interface automated testing by selecting and executing the corresponding test cases on the testing platform, without needing to repeatedly write and execute the same test steps.
[0172] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 50 includes:
[0173] The electronic device 50 may include one or more processors 501 with processing cores, one or more memory 502s of computer-readable storage media, communication components 503, and other components. The processor 501, memory 502, and communication components 503 are connected via a bus 504.
[0174] In the specific implementation process, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to execute the above-mentioned automated testing method.
[0175] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0176] In the above Figure 5In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0177] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0178] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0179] In some embodiments, a computer program product is also provided, comprising a computer program or instructions that, when executed by a processor, implement the steps in any of the above-described automated testing methods.
[0180] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0181] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0182] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the automated testing methods provided in embodiments of this application.
[0183] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0184] According to one aspect of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium.
[0185] Since the instructions stored in the storage medium can execute the steps of any of the automated testing methods provided in the embodiments of this application, the beneficial effects that any of the automated testing methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0186] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0187] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. An automated testing method, characterized in that, The method includes: In response to an operation on the automated testing platform, the identifier of the target test case is obtained; According to the preset correspondence and the identifier of the target test case, the target data in the target test case database table is retrieved. The correspondence represents the correspondence between the identifier of the test case and the data in the target test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table. Based on the target data, construct the target test case script; Based on the target test case script, an automated user interface test report is generated; The step of retrieving target data from the target test case database table based on the preset correspondence and the identifier of the target test case includes: Based on the correspondence and the identifier of the target test case, determine the test case step information and browser information corresponding to the identifier of the target test case. The test case step information includes the element identifier and keyword identifier of the target test case. Based on the element identifier and keyword identifier of the target test case, determine the element information and keyword information corresponding to the element identifier and keyword identifier of the target test case from the target test case database table; The browser version corresponding to the target test case is determined based on the browser information.
2. The method according to claim 1, characterized in that, Before retrieving target data from the target database table based on the preset correspondence and the identifier of the target test case, the method further includes: In response to the user's operation of adding test cases to the automated testing platform, new test case data is obtained. The new test case data includes newly added data in the keyword database table, element database table, test case step database table, and test case information database table. The newly added test case data is saved to the corresponding test case database table.
3. The method according to claim 2, characterized in that, The automated testing platform displays a test case management interface, a keyword management interface, and an element management interface. The test case management interface includes a test case step name input area, an element selection area, and a keyword selection area. In response to a user's operation to add a test case to the automated testing platform, the platform obtains new test case data, including: In response to the user's input operation in the test case step name input area of the test case management interface, the name and parameter value data of each step of the newly added test case are obtained; In response to the user's selection operation in the element selection area of the test case management interface, the element data of the newly added test case is obtained; In response to the user's selection of keywords in the keyword selection area of the test case management interface, keyword data for new test cases is obtained; Based on the keyword management interface and element management interface, display keywords and manage the elements of the test page; Based on the name, parameter value data, element data, keyword data, and browser version data of each step of the newly added test case, the new test case data and test case data identifier are obtained.
4. The method according to claim 3, characterized in that, The method further includes: When there are more than two new test case data entries, the new test case data is processed by aggregation, and the aggregated new test case data is saved to the corresponding test case database table.
5. The method according to claim 1, characterized in that, The step of obtaining the user interface automated test report based on the target test case script includes: Identify the target automated testing tool and the control commands sent by the remote browser driver; The target browser is launched according to the control instructions sent by the target automated testing tool and the remote browser driver, wherein the version of the target browser corresponds to the browser version information in the target test case script; Based on the target browser, execute the target test cases to obtain an automated user interface test report.
6. The method according to claim 5, characterized in that, The step of launching the target browser based on the control commands sent by the target automated testing tool and the remote browser driver includes: Obtain the browser version information from the target test case script; Based on the browser version information in the target test case script, a Docker image of the target browser is obtained, wherein the Docker image of the target browser corresponds to the browser version information in the target test case script; Start the Docker image container based on the Docker image of the target browser; Launch the target browser based on the Docker image container.
7. The method according to claim 5, characterized in that, The step of executing the target test cases based on the target browser to obtain a user interface automated test report includes: Determine the browser driver for the target browser and the output directory for the test report; Run automated testing tools based on the browser driver of the target browser; Based on the automated testing tool after it has been run, execute the target test cases to obtain an automated user interface test report; Copy the user interface automation test report to the output directory of the test report.
8. The method according to claim 7, characterized in that, The method further includes: Obtain the screen recording requirements, log requirements, and target directory for the target test case; Based on the screen recording and logging requirements of the target test case, the video file and log file of the target test case are obtained; Copy the video file and log file to the target directory.
9. An automated testing device, characterized in that, include: The acquisition module is used to acquire the identifier of the target test case in response to the operation of the automated testing platform; The retrieval module is used to retrieve target data from the target test case database table according to the preset correspondence and the identifier of the target test case. The correspondence represents the correspondence between the identifier of the test case and the data in the test case database table. The target test case database table includes a keyword database sub-table, an element database sub-table, a test case step database sub-table, and a test case information database sub-table. The construction module is used to construct target test case scripts based on the target data; The determination module is used to obtain an automated test report of the user interface based on the target test case script; The retrieval module is specifically used to determine, based on the correspondence and the identifier of the target test case, the test case step information and browser information corresponding to the identifier of the target test case, wherein the test case step information includes the element identifier and keyword identifier of the target test case; based on the element identifier and keyword identifier of the target test case, determine the element information and keyword information corresponding to the element identifier and keyword identifier of the target test case from the target test case database table; and determine the browser version corresponding to the target test case based on the browser information.
10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the automated testing method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the automated testing method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
UI automatic test method and device, electronic equipment and storage medium
CN113238953A
Automatic interface testing method and device, equipment and storage medium
CN115454869A