A test method and test platform
By automating the extraction and generation of test scripts, the problems of low efficiency and high manual costs in testing web application configuration data are solved, achieving efficient and accurate automated testing.
Patent Information
- Application Number
- CN202211529781.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-30
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-11-30
AI Technical Summary
In existing technologies, testing the configuration data of web applications is inefficient and incurs high labor costs, and the test results are easily affected by the subjective factors of technical personnel.
By automatically extracting target elements from configuration data, generating test scripts, and running them, automated testing is achieved, reducing the complexity of manually writing scripts and the impact of subjective factors.
It improved testing efficiency, reduced human resource consumption, and increased the accuracy of test results and repair efficiency.
Smart Images

Figure CN116244171B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software testing, and particularly relates to a testing method and a testing platform. BACKGROUND
[0002] A web application (web app or web application) is an application software operating on the Internet or an intranet through a browser, and the business requirements of a user are completed through the jump between web pages. At present, in order to facilitate the use of the web application by the user, configuration data recorded in hyper text markup language (HTML) is usually provided for the user, which is used to identify the display mode of the content in the web page, such as the font, the size of the picture and the like, so as to facilitate the user to understand and learn the use method of the web app. With the update and iteration of the version of the web app, the configuration data needs to be updated accordingly. In order to make the use result obtained by the use method recorded in the configuration data consistent with the actual use result, the technical personnel usually test the use method recorded in the configuration data, specifically through the manual testing mode, write a test script and run the script to obtain the test result. However, the testing mode has low efficiency and high labor cost. SUMMARY
[0003] Embodiments of the present application provide a testing method and a testing platform, which are used to improve the testing efficiency.
[0004] To achieve the above object, the embodiments of the present application adopt the following technical solutions:
[0005] In a first aspect, a testing method is provided, comprising: obtaining configuration data of a web application; wherein the configuration data is used to describe the operation process of the web application; extracting a target element from the configuration data; wherein the target element is an element used to represent a test step of a target function of the web application; generating a test script of a target test case according to the target element; wherein the target test case is used to test the target function; and running the test script to obtain a test result.
[0006] Since the current configuration data is mainly tested by manually writing test scripts, a lot of manpower and time cost are consumed, the test efficiency is low, and the test script is completely dependent on the technical personnel, so that the test result is mixed with many subjective factors, which affects the test result. The above scheme provided by the application helps to extract the target elements of the test script based on the non-regular configuration data, greatly reduces the complexity of the test script writing and the many subjective factors increased in the process of manually writing the script. Further, based on the test script, automatic operation is realized, so as to help the technical personnel to adjust the configuration data and / or the web application itself according to the test result, improve the test efficiency and the test result accuracy, and save the time cost.
[0007] In a possible implementation, the target elements are extracted from the configuration data, including: extracting the target elements from the configuration data according to a predefined data structure; wherein the data structure includes: a field for carrying an identifier of a test case and a field for carrying a test step of the test case; the test step is represented by at least one element; wherein the field for carrying the identifier of the test case is used to indicate an element in the target elements that identifies a target function, and the field for carrying the test step of the test case is used to indicate an element that implements the target function.
[0008] This possible implementation provides a specific implementation of extracting target elements from configuration data. By predefining a data structure, it is helpful to automatically extract the required target elements based on the configuration data, which facilitates the generation of subsequent test cases.
[0009] In a possible implementation, the elements include at least one of the following: a positioning element, a mouse event, an input operation, and a window switching; wherein the positioning element is used to represent an operable object of the web application in the page.
[0010] This possible implementation provides specific forms of elements in the configuration data, and each element constitutes a step in the test case.
[0011] In a possible implementation, the method further includes: when the test result is inconsistent with the preset test result, outputting prompt information; wherein the prompt information is used to indicate that the target test case fails.
[0012] This possible implementation helps users to know the test result, and to repair the configuration data in time according to the test result, thereby improving the repair efficiency.
[0013] In a possible implementation, the prompt information further includes a test failure type of the target test case, and the failure type includes that the test script is completed, the test result is inconsistent with the preset test result, or the failure type further includes that the test script is not completed.
[0014] In the possible implementation, the prompt information known by the user further includes a test failure type, so that the user knows the specific reason for the test failure, and the repair efficiency is improved by determining a repair scheme according to the specific reason.
[0015] In a possible implementation, the method further includes: when the test result is inconsistent with the preset test result, determining a target solution corresponding to the target function according to a correspondence between the plurality of functions of the web application and the plurality of solutions; wherein the solution corresponding to a function represents a solution when the function in the configuration file has a problem; and outputting the target solution.
[0016] In the possible implementation, the corresponding solution is prompted to the user when the test result is inconsistent with the preset test result, and the repair efficiency is improved.
[0017] In a possible implementation, the method further includes: when the test result is inconsistent with the preset test result, outputting description information of the problem.
[0018] In the possible implementation, the related description information of the test failure is provided to the user when the test result is inconsistent with the preset test result, so that the tester understands the program content in the test, and feeds back the test result or performs repair in a timely manner.
[0019] In a second aspect, a test platform is provided, including a processor and a communication interface, the processor being connected with the communication interface; the communication interface is configured to acquire configuration data of a web application; wherein the configuration data is configured to describe an operation process of the web application; the processor is configured to extract a target element from the configuration data; wherein the target element is an element representing a test step of a target function of the web application; the processor is further configured to generate a test script of a target test case according to the target element; wherein the target test case is configured to test the target function; and the processor is further configured to run the test script to obtain a test result.
[0020] In a third aspect, a test device is provided, including functional units for executing any one of the methods provided in the first aspect, and the actions performed by each functional unit are implemented by hardware or by hardware executing corresponding software. For example, the test device can include an acquisition unit and a processing unit. The acquisition unit is configured to acquire configuration data of a web application; wherein the configuration data is configured to describe an operation process of the web application. The processing unit is configured to extract a target element from the configuration data; wherein the target element is an element representing a test step of a target function of the web application. The processing unit is further configured to generate a test script of a target test case according to the target element; wherein the target test case is configured to test the target function. The processing unit is further configured to run the test script to obtain a test result.
[0021] In a fourth aspect, a testing device is provided, comprising: a processor and a memory. The processor is connected with the memory, and the memory is configured to store computer-executable instructions. The processor executes the computer-executable instructions stored in the memory, so as to implement any one of the methods provided in the first aspect.
[0022] In a fifth aspect, a chip is provided, comprising: a processor and an interface circuit; the interface circuit is configured to receive code instructions and transmit the code instructions to the processor; and the processor is configured to execute the code instructions to implement any one of the methods provided in the first aspect.
[0023] In a sixth aspect, a computer-readable storage medium is provided, comprising computer-executable instructions. When the computer-executable instructions are executed on a computer, the computer is caused to execute any one of the methods provided in the first aspect.
[0024] In a seventh aspect, a computer program product is provided, comprising computer-executable instructions. When the computer-executable instructions are executed on a computer, the computer is caused to execute any one of the methods provided in the first aspect.
[0025] The technical effects brought by any one of the implementation manners of the second aspect to the seventh aspect can be referred to the technical effects brought by the corresponding implementation manners in the first aspect, which will not be described herein. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 A composition diagram of a search engine web page provided by an embodiment of the present application;
[0027] Figure 2 A composition diagram of a communication device provided by an embodiment of the present application;
[0028] Figure 3 A flow diagram of a test configuration data provided by an embodiment of the present application;
[0029] Figure 4 A flow diagram of a test configuration data provided by an embodiment of the present application;
[0030] Figure 5 A flow diagram of a test configuration data provided by an embodiment of the present application;
[0031] Figure 6 An interface diagram of a user operation provided by an embodiment of the present application;
[0032] Figure 7 A composition diagram of a test platform provided by an embodiment of the present application. DETAILED DESCRIPTION
[0033] In the description of the present application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is only a description of the relationship between the associated objects, which means that there can be three relationships, for example, A and / or B, which can mean: A exists alone, A and B exist together, and B exists alone. In addition, "at least one" means one or more, and "multiple" means two or more. "First", "second", and the like do not limit the quantity and execution order, and "first", "second", and the like do not necessarily mean different.
[0034] It should be noted that in this application, "exemplary" or "for example" means to serve as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the use of "exemplary" or "for example" is intended to present the relevant concept in a specific manner.
[0035] Currently, web applications provide remote control implementation for server business deployment, system monitoring and maintenance. Users access browsers and operate on web pages to complete business requirements. In order to facilitate users to understand and learn the functions that can be implemented by web applications, configuration materials describing the contents of the web pages are usually provided for users. For example, Figure 1 As shown, it is a composition diagram of a search engine web page. The diagram includes an input box, a search operation option, a history search record, and history search terms "patent development history" and "patent application process". The input box, search operation option, history search term and other elements in the diagram can receive user operations and respond to corresponding messages. For example, the input box is used to receive user input. The search operation option represented by the "magnifying glass" icon is used to search for user input content after the user clicks it with the mouse. The history search record is used to indicate that the terms displayed below it are the content searched in the past. In addition, the history search term can be used to receive user mouse click operations and jump to the corresponding search result interface. The above Figure 1 The examples described above can be described by HTML to generate configuration materials. For example, the size of the input box, the arrangement of the history search terms, and the like.
[0036] However, with the frequent changes of the interface of the web application in the update iteration, including the modification of elements and the operation mode of the elements, the configuration material describing the interface needs to be updated accordingly, and the process is relatively complex and tedious. After obtaining the update result of the configuration material, in order to make the content recorded in the configuration material consistent with the functions contained in the web application, the configuration material is usually tested at present, which includes starting the web application and testing the operation method of each element in the test webpage and whether the response operation result is consistent with the content recorded in the configuration material, so that in the process of using the web application by the user, the user can refer to the configuration material consistent with the functions provided by the web application, and provide a good application experience for the user, and when the web application is used to remotely control the server, the remote operation efficiency of the user for the server is provided. The above test process in the prior art usually adopts a manual testing method. According to the content recorded in the configuration material, a test script is manually written by a technical personnel through writing a test requirement analysis and a test case design, and then the test result is obtained by running the test. In the case that the content of the configuration material is relatively large, the above method has low efficiency and high complexity; in which, the participation of the technical personnel in the test process is relatively high, and the subjective factors in the test result are relatively large, which affects the judgment of the test result.
[0037] To this end, the embodiment of the present application provides a method for testing configuration material, automatically extracts elements required for testing according to the configuration material, and automatically generates a test script for testing, thereby saving human resources and greatly reducing the influence of subjective factors of personnel on the test result, and improving the test efficiency.
[0038] The method for testing configuration material provided by the embodiment of the present application can be a stand-alone communication device. The embodiment of the present application does not limit the specific form of the communication device, which can be a terminal or a server. The terminal can be a mobile phone, an augmented reality (AR) device, a virtual reality (VR) device, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and the like. The server can be a physical or logical server.
[0039] In hardware implementation, the corresponding functions can be implemented by a communication device as shown in Figure 2 As shown in Figure 2 Fig. 2 is a hardware structure schematic diagram of a communication device 20 provided by the embodiment of the present application.
[0040] Figure 2The illustrated communication device 20 can include a processor 201, a memory 202, a communication interface 203, and a bus 204. The processor 201, the memory 202, and the communication interface 203 can be connected through the bus 204.
[0041] The processor 201 is a control center of the communication device 20, and can be a general central processing unit (CPU), or other general processor, etc. The general processor can be a microprocessor or any conventional processor, etc.
[0042] As an example, the processor 201 can include one or more CPUs, such as the CPU 0 and the CPU 1 illustrated in FIG. 2. Figure 2
[0043] The memory 202 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
[0044] In one possible implementation, the memory 202 can exist independently of the processor 201. The memory 202 can be connected to the processor 201 through the bus 204, and used to store data, instructions, or program code. When the processor 201 invokes and executes the instructions or program code stored in the memory 202, the test method provided by the embodiments of the present application can be implemented.
[0045] In another possible implementation, the memory 202 can also be integrated with the processor 201.
[0046] The communication interface 203 is used for the communication device 20 to be connected with other devices through a communication network, which can be an Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 203 can include a receiving unit for receiving data, and a sending unit for sending data.
[0047] The bus 204 can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, Figure 2 In the drawings, only one thick line is used to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0048] It should be noted that Figure 2 The structure shown in the figure does not constitute a limitation on the communication device 20, except Figure 2 In addition to the components shown, the communication device 20 can include more or fewer of the components shown, or combine certain components, or different component arrangements. For example, the communication device 20 further includes a display screen for displaying images, videos, and the like. The display screen includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the communication device 20 can include 1 or N display screens, N being a positive integer greater than 1. In the embodiments of the present application, the display screen can display test results and receive user operations on the communication device interface.
[0049] As Figure 3 The flowchart of a method for testing configuration data provided by the embodiments of the present application is shown. Figure 3 The method shown can be applied to Figure 2 The communication device shown, hereinafter referred to as the first device, includes the following steps S301-S304.
[0050] S301, obtaining configuration data of a web application, wherein the configuration data is used to describe the operation process of the web application.
[0051] In a possible implementation, the configuration profile is generated in HTML. The document written in HTML is displayed as content in a web page of the web application used by the user through a browser. As described above, the configuration profile describes the operation process of the web application, including operation objects, actions and operation results. The operation object refers to an element in the web page. The action refers to a mouse operation or an input operation performed on the element in the web page. The operation result refers to a result obtained in response to the action performed on the operation object, for example, jumping to another page.
[0052] S302, extracting a target element from the configuration profile, wherein the target element is an element used to represent a test step of a target function of the web application.
[0053] Optionally, the configuration profile generated in HTML includes a plurality of HTML tags, and the HTML tags are used to mark different contents constituting the text. The first device extracts the target element based on the HTML tags. The HTML tags usually appear in pairs and are formed in the form of angle brackets. For example, and constitute a pair of tags. The content of the web page is contained in the tags. In addition, information such as title, character format, language, compatibility, keyword, description and the like is displayed in the tags, and the content to be displayed by the web page needs to be nested in the tags. For example, the title is nested in the tags, and the content to be displayed by the web page is nested in the tags. <title>indicates,< / title> Lists of items, such as Figure 1 "History of search records" in
[0054] It should be noted that the HTML tags appear in the form of single tags, and the values need to be assigned in the tag attributes. For example, <input type="text"value="按钮">
[0055] In a possible implementation, the first device extracts the target element from the configuration material according to a predefined data structure; wherein the data structure includes a field for carrying an identifier of a test case and a field for carrying a test step of the test case. The test step is characterized by at least one element; the identifier of the test case can include a case number, a case name, etc.
[0056] In an example, the predefined data structure includes a case name and a test step. The case name refers to the identifier of the test case. The test step refers to the test step of the test case. In combination with the above example, the case name is determined according to the title, and the test step is determined according to the items in the list. The test step further includes at least one element for describing the test step. The element includes at least one of the following: a positioning element, a mouse event, an input operation, and a window switching.
[0057] The positioning element refers to an interface element, which can also be understood as an operation object on which the user operates in the interface to achieve the step. For example, Figure 1 the input box and the search operation option of the web application in the page in
[0058] The mouse event refers to the way in which the user performs the mouse operation, including single click, left click, right click, double click, etc. For example, Figure 1 the search operation option can be operated by receiving the user's mouse click.
[0059] The input operation refers to the operation of inputting content by the user. For example, Figure 1 the input box receives the input operation of the user.
[0060] The window switching refers to the page pop-up or jump in response to the input operation or mouse event of the user on the positioning element. Specifically, the page address of the page pop-up or jump can be indicated. The page address usually refers to the uniform resource identifier (URI), which is used to locate information resources on the web, such as pictures, videos, programs, etc.
[0061] It can be understood that the above test steps at least include one of the above described elements to describe the way the step is implemented. For example, in the test case for "history search record", two parallel steps of "patent development history" and "patent application process" are included, and the two parallel test steps include the "click" mouse event and the target address of window switching. Then the test step is composed of mouse event and window switching, which is used to describe that the user clicks "patent development history" or "patent application process" to jump to the corresponding page address respectively. Figure 1
[0062] Optionally, the predefined data structure further includes a use case number, which refers to a serial number of the test case extracted or identified according to the configuration file. Specifically, the use case number is determined according to the identified use case name. For example, one test case is for the input box and search operation option, and another test case is for the history search content. Based on the identification order of the configuration file, they correspond to a use case number respectively.
[0063] It should be noted that the target element is a collection of elements in each test step of each test case described above.
[0064] S303, generating a test script of the target test case according to the target element.
[0065] The target test case is used to test the target function.
[0066] It can be understood that the test script is based on the browser in the subsequent test process, and the information of the HTML tag is displayed on the webpage, interacted with the user, and completed between the webpages to meet the business needs of the user. In the browser, in order to realize the interaction with the user, a script running rule, that is, a document object model (DOM), is provided, so that the target element generates a script according to the DOM, and realizes the interaction with the user after running.
[0067] Optionally, the first device extracts the target element based on the predefined data structure in the above step S302, and correspondingly, generates a test script of the target test case corresponding to the predefined data structure by using the extracted target element.
[0068] In a possible implementation, the first device generates the test script based on the selenium tool. Selenium is a tool for running test scripts in browsers to realize web application testing. Specifically, the user can define the test script according to the syntax of selenium based on the above data structure.
[0069] It should be noted that there can be multiple test cases identified based on the step S302 described above, and generally, the first device executes step S303 to generate a test script corresponding to each test case after obtaining the target elements constituting all test cases in the configuration data.
[0070] Optionally, the test script is a test script written in python language. It can be understood that the language of the test script can be any language supported by the selenium tool.
[0071] S304, running the test script to obtain the test result.
[0072] Optionally, the test script is run based on the selenium tool. The selenium tool includes a tool capable of calling different browsers to run the test script, i.e. Webdriver. For example, the first device calls Webdriver to drive the Chrome browser through the selenium tool, and starts the web application to be tested, thereby establishing a complete communication session link. After the connection is successful, the test script is run in the web application to be tested on the Chrome browser, each page is accessed according to the test page path, and the test case results are collected respectively.
[0073] It can be understood that at least one test script is generated based on the target elements extracted from the configuration data, and each test script corresponds to a test case. The process of running each test script by the first device is the process of testing the corresponding function for each test case. The function implemented by each test case is the business function that the web application can provide to the user. In the implementation process of each business function of the web application, different functions are usually executed according to different operations of the user. The correspondence between the operation of the user and the function executed is reflected by each element of the above test steps, and the test script is run based on the operation of the user described in the configuration data to execute the corresponding action, such as requesting business data from the server carrying the web application.
[0074] In one possible implementation, the web application to be tested is started based on Webdriver to obtain the page of the web application. The implementation is achieved through steps as shown in Figure 4 , including steps S401-S405.
[0075] S401, the first device starts a browser.
[0076] The browser is an application program used to retrieve, display and deliver web information resources, and the web information resources are located by a page address.
[0077] S402, the first device sends an initial page request message to a server carrying a web application through a browser.
[0078] The initial page request message is used to request the server to transmit initial page data of the web application to the first device. For example, the initial page request message is an HTTP request.
[0079] Correspondingly, the server receives the initial page request message.
[0080] In a possible implementation, step S402 can be implemented in response to an operation of a user inputting a page address of the initial page in the browser, or an operation of the user on other interface elements in the browser.
[0081] S403, the server parses the initial page request message.
[0082] It can be understood that the initial page request message contains identification information of the initial page, and the server obtains the initial page identification information by parsing the initial page request message. Further, the server derives initial page data according to the initial page identification information.
[0083] Optionally, the initial page identification information includes language and other format information used by the browser, which is used by the server to determine the format of the derived initial page data.
[0084] S404, the server sends an initial page response message to the first device.
[0085] The initial page response message contains the initial page data of the web application. For example, the server feeds back the initial page data according to the language used by the browser.
[0086] S405, the first device displays a page according to the page response message.
[0087] In a possible implementation, the first device performs page rendering according to the initial page data in the initial page response message, to obtain the displayed initial page. Page rendering is used to parse the initial page data and generate a visual image. For example, Figure 1 The interface diagram shown.
[0088] The above steps S401-S405, the first device obtains the web application and displays the initial page of the web application, for the user to implement related business functions in the page subsequently.
[0089] It should be noted that the above process can be used as part of test configuration data to test whether the initial page of the user running the web application is consistent with the information of the initial page recorded in the configuration data.
[0090] It can be understood that the contents of the web page described in the configuration file include page information of the web page, and the above process helps to realize the test process of displaying the initial page by obtaining the page data and determining whether the page data in the response of the verification server is consistent with the page information in the configuration file.
[0091] It can be understood that the configuration file has a corresponding relationship with the page provided by the web application, and the configuration file is usually used to describe the business functions that can be implemented by each element in the current page. Therefore, further, after obtaining the page in step S405, the method further includes steps S501-S505 as shown in the figure to run the test script formed by the configuration file corresponding to the page. Figure 5
[0092] S501, the first device performs a first operation of the user.
[0093] In a possible implementation, the first operation is a certain test step in the test case corresponding to the test script. For example, the first operation is the input operation or the mouse event of the user described above.
[0094] S502, the first device sends a page request message to the server based on the first operation.
[0095] Correspondingly, the server receives the page request message.
[0096] The page request message is the request message sent to the target address after determining the target address corresponding to the window jump based on the input operation or the mouse event of the user described above.
[0097] In an example, when the page request message is the request message sent based on the input operation of the user, the target address can be a database of the server, and the request message includes the input information of the user, which is used to find the content related to the input information in the database of the server.
[0098] In another example, the page request message is the request message sent based on the mouse event of the user, and the request message includes the specific address of the window jump, which is used for the server to obtain the first page based on the specific address.
[0099] S503, the server parses the page request message to generate the first page.
[0100] In a possible implementation, the server determines the first page based on the page request message and generates the first page. For example, based on the information input in the page request message, the server queries the relevant content in the database and generates the first page containing the input information. For another example, based on the target address contained in the page request message, the server obtains the corresponding first page according to the target address.
[0101] S504, the server sends the first page to the first device.
[0102] Correspondingly, the first device receives the first page sent by the server.
[0103] Optionally, the first page is an updated initial page. The first page can be a page formed by modifying part of the interface elements based on the initial page.
[0104] Optionally, the first page is a new page jumped according to the window switching.
[0105] S505, the first device displays the first page.
[0106] It should be noted that the above step S505 is an optional step. In a possible implementation, the first device can display the first page, so that the user can intuitively perceive the first page, thereby facilitating the user to optimize the page through the display to the user. Alternatively, the first device can also not display the first page, but only need to determine whether the obtained page response message is consistent with the result recorded in the configuration data, so as to determine the test result, without the need to display the running result through the first device.
[0107] It can be understood that through the above steps S501-S505, the first device completes the process of automatically running the test script and obtains the running result. In the above, the first operation of the user is the test process of one step in the test case, and the other steps are tested one by one in the above manner; further, each test case is tested step by step in the above manner. The first device can obtain the test result based on the running result, specifically, the first device compares the running result with the preset test result to obtain the test result. The preset test result refers to the running result recorded in the configuration data in advance.
[0108] In actual applications, the first operation of the user can also include selecting a certain interface element, and responding to the operation based on the test script. For example, Figure 6 As shown, the user selects the first interface element in the interface, and in response to the operation, the first device displays a drop-down menu, the operable interface elements contained in the drop-down menu can be used for further selection by the user, and different selections can be used to request different pages from the server. In the above example, the test script contains various operations that can be performed by the user, wherein the response results obtained by the first device locally for the operations of the user are contained, without being limited to Figure 5 In the described steps, the process of interacting with the server based on the operation of the user is not limited.
[0109] Optionally, when the test result is inconsistent with the preset test result, output prompt information; wherein the prompt information is used to indicate that the target test case fails.
[0110] In a possible implementation, the preset test result is a page corresponding to a target address, and if the page address obtained by the test result is different from the target address, it is considered that the test result is inconsistent with the preset result.
[0111] It can be understood that in the above possible implementation, two cases are included, i.e., the test step fails to successfully jump to the target page, and the target page jumped to is different from the target page in the preset test result.
[0112] Optionally, the above prompt information further includes a test failure reason of the target test case, and the failure reason includes that the test result is inconsistent with the preset test result, or the failure reason further includes that the test result is not executed completely.
[0113] Specifically, the prompt information includes specific information of the above test failure reason, such as the above test step fails to successfully jump to the target page, indicating that the test result is not executed completely. Or, the target page jumped to by the test step is different from the target page in the preset test result, indicating that the test result is inconsistent with the preset test result.
[0114] Optionally, the above prompt information includes a test case name.
[0115] Optionally, the above method further includes generating a test report based on the prompt information. Wherein the test report is used to record the prompt information corresponding to at least one test case name.
[0116] It should be noted that by testing in the above manner, a technician can know the test result by checking the test report, so as to adjust the configuration data and / or the web application itself based on the test result, greatly improving the test efficiency, and excluding many subjective factors in the test process, improving the accuracy of the test result, and saving time cost.
[0117] Optionally, before outputting the prompt information, the first device obtains a statistical result based on the prompt information. The statistical result is used to represent information obtained by further processing and analyzing the prompt information.
[0118] In a possible implementation, the statistical result includes a use case pass rate. The use case pass rate refers to a proportion of test cases that are consistent with preset test results among all test cases after the test cases extracted from the configuration file are used to generate corresponding test scripts and run. For example, if the test cases extracted from the configuration file include 100 test cases, and 90 test cases are consistent with the preset test results after the test scripts are run, the use case pass rate is calculated as 90%.
[0119] In another possible implementation, the statistical result includes a problem classification. The problem classification refers to a problem situation when the test result is inconsistent with the preset test result. For example, the target address of the window switching is different, or the corresponding page response message cannot be generated based on the page request message. The problem classification can be represented by different identifiers. For example, when the positioning element corresponding to the first operation of the user cannot be positioned, the problem identifier can be NoSuchElementException, indicating that the element cannot be found. Or, when the positioning element corresponding to the first operation of the user does not have a corresponding attribute, the problem identifier can be NoSuchAttributeException. For example, the spelling of the input information in the input box is limited to uppercase letters, but the configuration file does not limit it, so when the script is run, it indicates that the element does not have this attribute. Or, when the positioning element corresponding to the first operation of the user does not execute a corresponding window pop-up, the problem identifier can be NoAlertPresentException, indicating that there is no pop-up window. Or, when the window switching corresponding to the first operation of the user does not have a corresponding embedded another web page, the problem identifier can be NoSuchFrameException, indicating that the specified inline frame (frame or iframe, a label in HTML, which is a document in a document, or a floating frame) cannot be found.
[0120] Optionally, the statistical result includes the problem classification and a target solution. The problem classification and the target solution are in one-to-one correspondence. For example, as shown in Table 1, the identifier of each problem classification corresponds to a target solution.
[0121] Table 1: Correspondence between an identifier of a problem classification and a target solution
[0122]
[0123] Optionally, before outputting the prompt information, a visualization process is performed, and a visualization result is displayed. For example, according to the prompt information, an identifier of a problem category described in the prompt information is determined, and a table is output based on a correspondence between the identifier of the problem category and a target solution. The table includes a failed test case, and an identifier of a corresponding problem category and a corresponding target solution.
[0124] In this way, the non-regular configuration file can be automatically used to generate a test script, the influence of subjective factors introduced in the process of manually writing a script on a test result is reduced, and test efficiency is improved. Further, a visualization service is provided, and a corresponding solution is provided based on a problem category in a test result, problem solving efficiency is improved, and consistency between a configuration file and a web application is improved.
[0125] It should be noted that, in the implementation process of the above process, the first device communicates with a server carrying a web application. The server carrying the web application can also be one or more communication devices that deploy a web application, for example, a server cluster can also be implemented, and the application does not limit this. The specific form of the one or more communication devices can refer to the description of the communication device above, and the hardware composition of the one or more communication devices can refer to the related description of the server. Figure 2
[0126] The above mainly introduces the scheme of the embodiments of the application from the perspective of the method. It can be understood that, in order to implement the above functions, the communication device as the first device comprises at least one of the corresponding hardware structure and the software module for executing each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of the examples described in the embodiments disclosed in the present text, the application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is implemented in hardware or computer software driven hardware depends on the specific application and design constraints of the technical scheme. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the application.
[0127] The embodiments of the application can divide the functional units of the communication device according to the above method examples. For example, each functional unit can be divided according to each function, or two or more functions can be integrated in one processing unit. The integrated unit can be implemented in the form of hardware or software functional unit. It should be noted that the division of units in the embodiments of the application is illustrative, and is only a logical function division. When actually implemented, there can be another division method.
[0128] In a case where each functional module is divided according to each function, Figure 7 A possible structure of the communication device involved in the above embodiments is shown. As shown in the figure, the communication device 70 comprises an acquisition unit 701 and a processing unit 702. The acquisition unit 701 is configured to acquire configuration data of a web application; wherein the configuration data is used to describe the operation process of the web application. The processing unit 702 is configured to extract a target element from the configuration data; wherein the target element is an element used to represent a test step of a target function of the web application. The processing unit 702 is further configured to generate a test script of a target test case according to the target element; wherein the target test case is used to test the target function. The processing unit 702 is further configured to run the test script to obtain a test result. Figure 7
[0129] In an example, the extraction of the target element from the configuration data comprises: extracting the target element from the configuration data according to a predefined data structure; wherein the data structure comprises: a field used to carry an identifier of a test case and a field used to carry a test step of the test case; the test step is represented by at least one element; wherein the field used to carry the identifier of the test case is used to indicate an element in the target element that identifies the target function, and the field used to carry the test step of the test case is used to indicate an element that implements the target function.
[0130] In an example, the element comprises at least one of the following: a positioning element, a mouse event, an input operation, and a window switching; wherein the positioning element is used to represent an operable object of the web application in a page.
[0131] In an example, the communication device 70 further comprises an output unit 703 configured to output prompt information when the test result is inconsistent with a preset test result; wherein the prompt information is used to indicate that the target test case fails.
[0132] In an example, the prompt information further comprises a test failure type of the target test case, and the failure type comprises that the test script is run completely, and the test result is inconsistent with the preset test result, or the failure type further comprises that the test script is not run completely.
[0133] In an example, the processing unit 702 is further configured to determine a target solution corresponding to the target function according to a correspondence between a plurality of functions of the web application and a plurality of solutions when the test result is inconsistent with the preset test result; wherein the solution corresponding to a function is used to represent a solution when the function in the configuration data has a problem; and output the target solution.
[0134] In an example, the output unit 703 is further configured to output description information of the problem when the test result is inconsistent with the preset test result. In a case where each functional module is divided according to each function, Figure 7 A possible structure of the communication device involved in the above embodiments is shown. As shown in the figure, the communication device 70 comprises an acquisition unit 701 and a processing unit 702. The acquisition unit 701 is configured to acquire configuration data of a web application; wherein the configuration data is used to describe the operation process of the web application. The processing unit 702 is configured to extract a target element from the configuration data; wherein the target element is an element used to represent a test step of a target function of the web application. The processing unit 702 is further configured to generate a test script of a target test case according to the target element; wherein the target test case is used to test the target function. The processing unit 702 is further configured to run the test script to obtain a test result. Figure 7
[0129] In an example, the extraction of the target element from the configuration data comprises: extracting the target element from the configuration data according to a predefined data structure; wherein the data structure comprises: a field used to carry an identifier of a test case and a field used to carry a test step of the test case; the test step is represented by at least one element; wherein the field used to carry the identifier of the test case is used to indicate an element in the target element that identifies the target function, and the field used to carry the test step of the test case is used to indicate an element that implements the target function.
[0130] In an example, the element comprises at least one of the following: a positioning element, a mouse event, an input operation, and a window switching; wherein the positioning element is used to represent an operable object of the web application in a page.
[0131] In an example, the communication device 70 further comprises an output unit 703 configured to output prompt information when the test result is inconsistent with a preset test result; wherein the prompt information is used to indicate that the target test case fails.
[0132] In an example, the prompt information further comprises a test failure type of the target test case, and the failure type comprises that the test script is run completely, and the test result is inconsistent with the preset test result, or the failure type further comprises that the test script is not run completely.
[0133] In an example, the processing unit 702 is further configured to determine a target solution corresponding to the target function according to a correspondence between a plurality of functions of the web application and a plurality of solutions when the test result is inconsistent with the preset test result; wherein the solution corresponding to a function is used to represent a solution when the function in the configuration data has a problem; and output the target solution.
[0134] In an example, the output unit 703 is further configured to output description information of the problem when the test result is inconsistent with the preset test result.
[0135] In an example, the communication device 70 further comprises a storage unit 704. The storage unit 704 is configured to store computer-executable instructions, and other units in the communication device can perform corresponding actions according to the computer-executable instructions stored in the storage unit 704.
[0136] For specific descriptions of the above optional manners, refer to the foregoing method embodiments, which will not be described herein again. In addition, the descriptions of the explanations and beneficial effects of any one of the communication devices 70 provided above can refer to the corresponding method embodiments described above, which will not be described herein again.
[0137] The embodiments of the present application further provide a test platform, which can refer to the foregoing Figure 2 The hardware structure of the communication device is shown in the foregoing The test platform comprises: a processor and a communication interface, the processor being connected with the communication interface; the communication interface being configured to acquire configuration data of a web application; the configuration data being configured to describe an operation process of the web application; the processor being configured to extract a target element from the configuration data; the target element being an element used to represent a test step of a target function of the web application; the processor being further configured to generate a test script of a target test case according to the target element; the target test case being configured to test the target function; and the processor being further configured to run the test script to obtain a test result.
[0138] The test platform further comprises a memory. The memory can contain computer program codes. The processor is configured to execute the computer program codes stored in the memory, so as to implement the method provided by the embodiments of the present application.
[0139] In the implementation process, each step in the method provided by the embodiments of the present application can be completed by integrated logic circuits of hardware in the processor of the test platform or instructions in the form of software. The steps of the method disclosed by the embodiments of the present application can be directly embodied as execution completed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0140] The embodiments of the present application further provide a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program runs on a computer, the computer executes the method executed by any one of the communication devices provided above.
[0141] For the explanations and beneficial effects of the related content in any one of the computer readable storage media provided above, refer to the corresponding embodiments described above, which will not be described herein again.
[0142] The embodiments of the present application further provide a chip. The chip integrates a control circuit and one or more ports for implementing the functions of the communication device. Optionally, the functions supported by the chip can refer to the above, and will not be repeated here. Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be instructed by a program to relevant hardware to complete. The program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a random access memory, etc. The above-mentioned processing unit or processor can be a central processing unit, a general-purpose processor, an application specific integrated circuit (ASIC), a digital signal processor (DSP), a field programmable gate array (FPGA) or other programmable logic device, a transistor logic device, a hardware component or any combination thereof.
[0143] The embodiments of the present application further provide a computer program product containing instructions, which, when executed on a computer, cause the computer to perform any of the methods in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or data storage device such as one or more servers, data centers, etc. integrated with one or more media. The available media can be magnetic media (such as floppy disk, hard disk, magnetic tape), optical media (such as DVD), or semiconductor media (such as SSD), etc.
[0144] It should be noted that the above-mentioned devices for storing computer instructions or computer programs provided by the embodiments of the present application, such as but not limited to the above-mentioned memory, computer readable storage medium and communication chip, etc., all have non-volatility (non-transitory).
[0145] In the embodiments described above, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or data storage device including one or more servers, data centers, etc. integrated with the medium. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0146] Although the present application is described herein in conjunction with various embodiments, it is understood that other variations of the disclosed embodiments can be understood and effected by those skilled in the art in practicing the claimed application, from an inspection of the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and the indefinite articles "a" or "an" do not exclude a plurality. A single processor or other unit can fulfill the functions of several items recited in the claims. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
[0147] Although the present application is described herein in conjunction with specific features and embodiments thereof, it is understood that modifications and combinations can occur to those skilled in the art to which the present application pertains, within its spirit and scope. Accordingly, the description and drawings are to be regarded as illustrative in nature and are not to be taken as limiting the scope of the application as defined by the appended claims. Obviously, many modifications and variations of this application are possible in light of its teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, this application can be practiced otherwise than as specifically described.
Claims
1. A testing method, characterized in that, include: Obtain the configuration information of the web application; wherein the configuration information is used to describe the operation process of the web application; According to a predefined data structure, target elements are extracted from the configuration data; wherein the data structure includes: a field for identifying test cases and a field for identifying test steps of the test cases; the test steps are characterized by at least one element; wherein the field for identifying test cases is used to indicate the element in the target element that identifies the target function, and the field for identifying test steps of the test cases is used to indicate the element that implements the target function; wherein the target element is an element for identifying the test steps of the target function of the web application. A test script for a target test case is generated based on the target element; wherein the target test case is used to test the target function; Run the test script to obtain the test results.
2. The method according to claim 1, characterized in that, The elements include at least one of the following: positioning elements, mouse events, input operations, and window switching; wherein, the positioning elements are used to represent the operable objects of the web application on the page.
3. The method according to claim 1 or 2, characterized in that, The method further includes: When the test result is inconsistent with the preset test result, a prompt message is output; wherein, the prompt message is used to indicate that the target test case has failed.
4. The method according to claim 3, characterized in that, The prompt message also includes the test failure type of the target test case. The failure type includes the test script completing execution, the test result being inconsistent with the preset test result, or the failure type also includes the test script not completing execution.
5. The method according to claim 1 or 2, characterized in that, The method further includes: When the test results are inconsistent with the preset test results, the target solution corresponding to the target function is determined according to the correspondence between multiple functions and multiple solutions of the web application; wherein, the solution corresponding to a function is used to characterize the solution when the function in the configuration data has a problem. Output the target solution.
6. The method according to claim 1 or 2, characterized in that, The method further includes: When the test result is inconsistent with the preset test result, output a description of the problem.
7. A testing platform, characterized in that, Includes a processor and a communication interface, wherein the processor is connected to the communication interface; The communication interface is used to obtain configuration information of the web application; wherein, the configuration information is used to describe the operation process of the web application; The processor is configured to extract target elements from the configuration data according to a predefined data structure; wherein the data structure includes: a field for carrying an identifier of a test case and a field for carrying a test step of the test case; the test step is characterized by at least one element; wherein the field for carrying the identifier of the test case is used to indicate an element in the target element that identifies a target function, and the field for carrying the test step of the test case is used to indicate an element that implements the target function; wherein the target element is an element for representing a test step of the target function of the web application; The processor is further configured to generate test scripts for target test cases based on the target elements; wherein the target test cases are used to test the target functionality; The processor is also used to run the test script and obtain test results.
8. A chip, characterized in that, The chip includes a processor and an interface circuit; the interface circuit is used to receive code instructions and transmit them to the processor; the processor is used to execute the code instructions so that the chip implements the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer-executable instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes computer execution instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Method for generating script files to test Web application software and device thereof
CN101526919A
Webpage test method and terminal
CN105279076A
Test method and device
CN113110996A