Webpage testing method and device, electronic equipment, storage medium and computer program product

By determining the front-end UI framework program module and test instructions of the web page to generate UI component objects, the problems of poor code reusability and poor adaptability in the existing web page test methods are solved, and more efficient test code reuse and page change adaptation are achieved. , reducing development and maintenance costs.

CN118885382APending Publication Date: 2024-11-01CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410876882.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

The existing web page testing methods have poor reusability, poor adaptability and difficult writing, resulting in high development costs and high maintenance costs. The test script is too sensitive to changes in page elements and is difficult to adapt to page changes.

Method used

By determining the UI framework program module of the front-end UI framework used by the web page, the UI component object of the web page element is generated according to the test instructions, and the object is used for testing, avoiding the coupling between the test code and the web application, and realizing the reusability of the code and improve adaptability.

Benefits of technology

It improves the reusability and adaptability of test code, reduces the use of selectors such as CSS and XPATH in web testing, and reduces the difficulty of writing test cases and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885382A_ABST
    Figure CN118885382A_ABST
Patent Text Reader

Abstract

The invention discloses a webpage testing method and device, electronic equipment, a storage medium and a computer program product.The method comprises the steps that a UI frame program module, corresponding to a front-end UI frame used by a first webpage, in a testing execution program is determined; generating a UI component object corresponding to the webpage element in the first webpage according to a test instruction and the UI framework program module; and testing the first webpage according to the test instruction and the UI component object to obtain a test result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to a web page testing method, device, electronic device, storage medium and computer program product. Background Art

[0002] In the related art, for the testing scenarios of web applications, test codes are usually written for the tested web applications based on the page object model of the web application, keyword-driven testing and other methods to implement automated testing of the user interface (UI). This method has problems such as poor test code reusability, poor adaptability, and difficulty in writing. Summary of the invention

[0003] To solve the related technical problems, the embodiments of the present application provide a web page testing method, device, electronic device, storage medium and computer program product.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] The present invention provides a web page testing method, which includes:

[0006] Determine a UI framework program module corresponding to the front-end UI framework used by the first webpage in the test execution program;

[0007] Generate a UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module;

[0008] The first webpage is tested according to the test instruction and the UI component object to obtain a test result.

[0009] In the above solution, generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes:

[0010] Determine a web page element in the first web page according to at least one of the test instruction and the UI framework program module;

[0011] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0012] In the above solution, generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes:

[0013] Determine, according to at least one of the test instruction and the UI framework program module, a positioning rule for the interactive object specified by the test instruction;

[0014] Determining a web page element in the first web page according to the positioning rule;

[0015] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0016] In the above solution, determining the positioning rule of the interactive object specified by the test instruction according to at least one of the test instruction and the UI framework program module includes:

[0017] According to the interactive object specified by the test instruction, determining in the test configuration file a positioning rule for the interactive object specified by the test instruction; and / or

[0018] A positioning rule for the interactive object specified by the test instruction is generated according to a UI framework program module corresponding to the front-end UI framework used by the first page.

[0019] In the above solution, determining the webpage element in the first webpage includes:

[0020] According to the positioning rule of the interactive object specified by the test instruction, the web page elements in the first web page are determined within the page area specified by the test instruction; the positioning rule is determined according to at least one of the test instruction and the UI framework program module.

[0021] In the above solution, generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes:

[0022] Searching for a UI component corresponding to the first web page element according to a first document object model (DOM) node where the first web page element in the first page is located;

[0023] In the case where the UI component corresponding to the first webpage element is searched, generating a UI component object corresponding to the first webpage element according to the test instruction and the UI framework program module; or

[0024] If the UI component corresponding to the first webpage element is not found and / or the first condition is not met, searching for the UI component corresponding to the second webpage element according to the second DOM node, the second DOM node being the parent node of the first DOM node, and the second webpage element being the webpage element corresponding to the second DOM node;

[0025] When the UI component corresponding to the second web page element is searched, a UI component object corresponding to the second web page element is generated according to the test instruction and the UI framework program module.

[0026] In the above solution, the UI component object corresponding to the web page element is generated, including:

[0027] Determine the identifier of the first interface according to the test instruction and the first relationship, wherein the first relationship at least includes a correspondence between the test instruction and the identifier of the interface for converting the web page element to the UI component object;

[0028] A first interface in a UI framework program module corresponding to a front-end UI framework used by the first page is called to generate a UI component object corresponding to a web page element in the first web page.

[0029] In the above solution, the step of testing the first webpage according to the test instruction and the UI component object to obtain the test result includes:

[0030] According to the interactive action and / or interactive data specified by the test instruction, the second interface is called to test the first web page to obtain a test result; the second interface is a user-defined interface corresponding to the interactive action in the test configuration file, or a built-in interface of a UI component object corresponding to a web page element in the first web page.

[0031] In the above solution, the step of testing the first webpage according to the test instruction and the UI component object to obtain the test result includes:

[0032] Determine, among UI component objects corresponding to web page elements in the first web page, a UI component object corresponding to the interactive object specified by the test instruction;

[0033] According to the UI component object corresponding to the interactive object specified by the test instruction, the interactive action and / or interactive data specified by the test instruction, call the third interface to test the first web page to obtain the test result; the third interface is the user-defined interface corresponding to the interactive action in the test configuration file, or the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction.

[0034] In the above solution, before determining, among the UI component objects corresponding to the web page elements in the first web page, the UI component object corresponding to the interactive object specified by the test instruction, the method further includes:

[0035] Determine a first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, wherein the first list at least includes text related to the web page element and / or an identifier of a UI component object corresponding to the web page element;

[0036] According to the text contained in the first list and the identifier of the interactive object specified by the test instruction, the identifier of the UI component object corresponding to the interactive object is determined in the first list.

[0037] In the above solution, determining the first list according to the DOM node where the webpage element in the first webpage is located and / or the corresponding parent node includes:

[0038] Searching for text and a corresponding UI component of the first webpage element according to the first DOM node where the first webpage element is located;

[0039] When the text of the first webpage element and / or the corresponding UI component is found, the text of the first webpage element and / or the identifier of the corresponding UI component object is written into the first list; or

[0040] If the text and / or the corresponding UI component of the first web page element are not found, searching for the text and the corresponding UI component of the second web page element according to the second DOM node; the second DOM node is the parent node of the first DOM node, and the second web page element is the web page element corresponding to the second DOM node;

[0041] When the text of the second webpage element and / or the corresponding UI component are found in the search, the text of the second webpage element and / or the identifier of the corresponding UI component object are written into the first list.

[0042] In the above scheme, the method further comprises:

[0043] The test instruction is determined according to the test case.

[0044] The present application also provides a web page testing device, including:

[0045] A first determining unit, used to determine a UI framework program module corresponding to a front-end UI framework used by the first webpage in a test execution program;

[0046] A generating unit, configured to generate a UI component object corresponding to a web page element in the first web page according to a test instruction and the UI framework program module;

[0047] The testing unit is used to test the first webpage according to the testing instruction and the UI component object to obtain a testing result.

[0048] The embodiment of the present application also provides an electronic device, including: a processor and a communication interface; wherein,

[0049] The processor is used to determine the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program; generate UI component objects corresponding to the web page elements in the first web page according to the test instructions and the UI framework program module; test the first web page according to the test instructions and the UI component objects to obtain test results.

[0050] The embodiment of the present application also provides an electronic device, including a processor and a memory for storing a computer program that can be run on the processor.

[0051] Wherein, the processor is used to execute the steps of the above-mentioned web page testing method when running the computer program.

[0052] The embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned web page testing method are implemented.

[0053] The embodiment of the present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned web page testing method when executed by a processor.

[0054] In the web page testing method, device, equipment, storage medium and computer program product provided by the embodiment of the present application, the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program is determined; according to the test instruction and the UI framework program module, the UI component object corresponding to the web page element in the first web page is generated; according to the test instruction and the UI component object, the first web page is tested to obtain the test result. In the above scheme, by determining the UI framework program module corresponding to the front-end UI framework used by the first web page, the first web page is tested according to the UI framework program module and the test instruction, thereby avoiding the coupling of the test code with the Web application, so that the web pages or Web applications using the same front-end UI framework can reuse the same set of test codes, thereby improving the reusability of the test code; and according to the test instruction and the UI framework program module, the conversion of the web page elements to the UI component objects is automatically completed, thereby improving the adaptive ability of the test code to the page changes, reducing the use of selectors such as Cascading Style Sheets (CSS), Extensible Markup Language (XML) Path Language (XPATH, XML Path Language) in web page testing, thereby reducing the difficulty of writing test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a schematic diagram of a web page testing method flow in an embodiment of the present application;

[0056] Figure 2 This is a schematic diagram of the UI framework program module structure of an embodiment of the present application;

[0057] Figure 3 A schematic diagram of the process of traversing DOM nodes in a DOM tree according to an embodiment of the present application;

[0058] Figure 4 This is an example of an HTML source code fragment corresponding to the first DOM tree in the embodiment of the present application;

[0059] Figure 5 This is the first DOM tree example of the embodiment of the present application;

[0060] Figure 6 This is a flow chart of a web page testing method according to an embodiment of the present application;

[0061] Figure 7 This is a schematic diagram of the structure of a web page testing device according to an embodiment of the present application;

[0062] Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0063] In related technologies, UI automation testing tools are used to automatically execute test cases and implement UI automation testing, which greatly improves testing efficiency and reduces testing workload and labor costs. Commonly used UI automation testing tools include: Selenium, Playwright, Puppeteer, etc. However, UI automation testing technologies based on page object mode, keyword-driven methods, etc. still have the following problems:

[0064] 1) Usually developed for a single Web system under test, the test script is highly coupled with the Web system under test, and has poor reusability. For different Web systems under test, a large amount of different code development is required, resulting in high development costs;

[0065] 2) The test script is too sensitive to changes in page elements, has poor adaptability, and has high maintenance costs. Since the positioning and testing methods of page elements have been determined when the test case is written, when page elements change, it is easy for the test script to no longer be used for the changed page. It is necessary to frequently respond to changes in page elements and modify the positioning and testing methods of page elements, resulting in high maintenance costs;

[0066] 3) Test script writing is difficult and has a high learning cost. When using the keyword-driven method for automated UI testing, it is usually necessary to establish a fixed keyword library, which requires a high level of skill for testers and requires testers to be familiar with the keyword library and the correspondence between keywords and test cases. However, with the evolution of the Web system being tested and the increase in page complexity, the number of keywords in the keyword library will also increase, leading to increased difficulty in learning and development.

[0067] Based on this, in various embodiments of the present application, the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program is determined; according to the test instructions and the UI framework program module, the UI component object corresponding to the web page element in the first web page is generated; according to the test instructions and the UI component object, the first web page is tested to obtain the test result. The above scheme avoids the coupling of the test code and the Web application by determining the UI framework program module corresponding to the front-end UI framework used by the first web page, so that the web pages or Web applications using the same front-end UI framework can reuse the same set of test codes, thereby improving the reusability of the test code; and according to the test instructions and the UI framework program module, the conversion of web page elements to UI component objects is automatically completed, thereby improving the adaptability of the test code to page changes, reducing the use of selectors such as CSS and XPATH in web page testing, and thus reducing the difficulty of writing test cases.

[0068] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0069] The present application embodiment provides a web page testing method, which is applied to an electronic device, wherein the electronic device includes a terminal and / or a server, such as Figure 1 As shown, the method includes:

[0070] Step 101: Determine the UI framework program module corresponding to the front-end UI framework used by the first webpage in the test execution program.

[0071] Here, the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program is determined through the test execution program. The first web page is a web page to be tested or a page to be tested, such as a page to be tested of a Web application or a page to be tested of a small program; the test execution program may include multiple UI framework program modules; the UI framework program module includes a front-end UI framework detection method, a positioning rule generation interface, and an interface for converting web page elements to UI component objects; the front-end UI framework corresponds to the UI framework program module one-to-one, and the UI framework program module corresponds to the front-end UI framework detection method one-to-one. Therefore, the front-end UI framework used by the first web page can be detected through the front-end UI framework detection method in the UI framework program module, thereby determining the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program; the first web page may correspond to one or more UI framework program modules.

[0072] The method for detecting the front-end UI framework used by the first web page is as follows: traverse the UI framework program module in the test execution program, and execute the front-end UI framework detection method in the UI framework program module to detect whether the first web page uses the front-end UI framework corresponding to the UI framework program module; when it is detected that the first web page uses the front-end UI framework in the UI framework program module, the UI framework program module is determined as the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program; when the front-end UI framework or the corresponding UI framework program module used by the first web page is determined, the front-end UI framework or the corresponding UI framework program module used by the first web page can be cached to reduce the detection frequency and improve the query efficiency. The front-end UI framework detection method can be implemented by performing feature detection on the HyperText Mark-up Language (HTML) source code, CSS, and JavaScript references of the first web page; for example, the front-end UI framework detection method can be implemented by detecting whether there is an HTML DOM node with a class attribute value starting with ant- in the first web page to determine whether the first web page uses the AntDesign framework.

[0073] It should be noted that the UI framework program modules corresponding to different front-end UI frameworks adopt the same interface specification. For example, the UI framework program module corresponding to the ElementUI framework and the UI framework program module corresponding to the AntDesign framework adopt the same interface specification; the UI framework program modules corresponding to different front-end UI frameworks adopt the same interface specification, so that testers or technicians can horizontally expand the UI framework program modules and add new UI framework program modules.

[0074] Since the front-end UI framework corresponds to the UI framework program module one by one, corresponding UI framework program modules can be designed for various front-end UI frameworks, and the UI framework program modules corresponding to various front-end UI frameworks can be encapsulated into the test execution program, so that the test execution program can be applicable to different pages to be tested and decoupled from the pages to be tested, so that multiple different pages to be tested or Web applications to be tested can reuse the same test execution program, thereby improving the reusability of the test code.

[0075] Step 102: Generate UI component objects corresponding to the web page elements in the first web page according to the test instruction and the UI framework program module.

[0076] Here, when the test instruction is obtained, the UI component object corresponding to the web page element in the first web page can be generated by calling the interface of converting the web page element to the UI component object in the UI framework program module; the test instruction includes the test instruction related to the UI operation and the test instruction unrelated to the UI operation; the generated UI component object has a corresponding relationship with the UI component in the front-end UI framework used by the first web page; the interface specifications of the same type of UI component objects are consistent, for example, in the UI framework program module corresponding to the ElementUI framework and the UI framework program module corresponding to the AntDesign framework, the UI component object corresponding to the UI component of the Form form adopts the same interface specification. Figure 2 The structure of the UI framework program module is shown, wherein the interface of the UI framework program module corresponding to the AntDesign framework and the interface of the UI framework program module corresponding to the ElementUI framework adopt the same interface specification; in the UI framework program module corresponding to the AntDesign framework and the UI framework program module corresponding to the ElementUI framework, UI component objects corresponding to the same type of UI components, such as UI component objects corresponding to form-type components (such as Form forms), UI component objects corresponding to table-type components (such as Table tables, Table Row tables and Table Cell cells), and UI component objects corresponding to input-type components (such as Raido radio buttons, Checkbox multiple-choice boxes and Select drop-down menus) adopt the same interface specification.

[0077] It should be noted that the test instruction may include at least an interactive object and / or an interactive action, and may also include interactive data and / or a page area range, and the page area range is used to indicate the range for searching for interactive objects in the first web page. In the case where the test instruction does not include a page area range, the range for searching for interactive objects in the first web page is the entire first web page. For example, in the case where the test instruction is "click to remember password in the login box", "click" is an interactive action, "remember password" is an interactive object, and "login box" is a page area range. The test instruction indicates searching for the interactive object "remember password" within the scope of the "login box" and clicking on the interactive object. For another example, in the case where the test instruction is "enter account = admin", "input" is an interactive action, "account" is an interactive object, and "admin" is interactive data. The test instruction indicates searching for the interactive object "account" in the entire first web page and entering the interactive data "admin".

[0078] The test instruction may be a preconfigured test instruction or may be obtained according to a test case. Based on this, in order to obtain a test instruction that is accurate or meets the test requirements, in one embodiment, the method further includes:

[0079] The test instruction is determined according to the test case.

[0080] Here, when the test case is obtained, the test case is added to the test execution program; the test instruction is obtained by reading and parsing the test case; and one test case can obtain one or more test instructions.

[0081] In addition, before determining the test instructions according to the test case, the test configuration can also be loaded into the test execution program; the test configuration file can include global configuration information of the site to be tested, that is, the site corresponding to the first web page, and / or configuration information for a specific page; the configuration information for a specific page can include a uniform resource locator (URL), and / or a user-defined Web element positioning rule, and / or a page area configuration; the Web element positioning rule is used to locate the Web element, for example, by calling a method corresponding to the positioning method name of the positioning rule to locate the Web element; the Web element positioning rule includes a method name and a method value of the positioning method, which is used to locate the Web element, for example, by calling a method corresponding to the positioning method name in the Web element positioning rule to locate the Web element; the positioning method can include a CSS selector, an XPATH selector, an identity identification number (ID, Identity The actual positioning method used can be determined according to the implementation of the test execution program and is not specifically limited here; for example, the positioning rule for viewing the password of the Web element is css=div.selectClass, which represents the use of the CSS selector to search for the Web element whose class attribute value in the div tag is selectClass in the web page, wherein the method name is css and the method value is div.selectClass; in addition, the positioning method can also be expanded as needed, for example, a positioning method for positioning by code can be added, and / or a positioning method for positioning by graphics can be added.

[0082] It should be noted that test cases and test configuration files can be stored and represented in various forms such as files and databases. For example, test configuration files can be stored and represented in .yaml format, and test cases can be stored and represented in .feature format written in Gherkin language.

[0083] Step 103: Testing the first webpage according to the test instruction and the UI component object to obtain a test result.

[0084] Here, when the test instruction and the UI component object corresponding to the web page element in the first web page are obtained, the first web page is tested according to the interactive action and / or interactive data specified by the test instruction, and according to the UI component object corresponding to the web page element in the first web page, to obtain the test result corresponding to the test instruction. For example, the interactive data specified by the test instruction is used as an input parameter, and the interaction with the first web page is completed by calling the interface method corresponding to the interactive action specified by the test instruction, and the test result is output. Among them, the interactive action specified by the test instruction can be referred to as the interactive action or the interactive action of the test instruction, the interactive data specified by the test instruction can be referred to as the interactive data or the interactive data of the test instruction, and the interactive object specified by the test instruction can be referred to as the interactive object or the interactive object of the test instruction; the interactive object, interactive action and interactive data refer to the components of the test instruction.

[0085] It should be noted that the programming interface of the test execution program can be opened so that testers can flexibly configure or expand the test content as needed through the programming interface, avoiding the test performance of the test execution program being limited by the recognition ability and compatibility of the test code itself, and the configuration or extension customized by the tester is independent of the test code, avoiding changes to the test code, making the test code more stable.

[0086] Since there are many web page elements in the first web page, it is necessary to find the web page elements for testing from the first web page, so as to use the web page elements for testing to perform testing to improve the test efficiency. Based on this, in one embodiment, generating the UI component objects corresponding to the web page elements in the first web page according to the test instructions and the UI framework program module includes:

[0087] Determine a web page element in the first web page according to at least one of the test instruction and the UI framework program module;

[0088] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0089] Here, before generating the UI component object corresponding to the web page element in the first web page, the web page element corresponding to the interactive object specified by the test instruction can be determined in the first web page according to at least one of the test instructions and the UI framework program module corresponding to the front-end UI framework used by the first web page, so that the UI component object corresponding to the web page element in the generated first web page includes the UI component object corresponding to the interactive object. For example, according to the test instruction, the positioning rule of the interactive object specified by the test instruction can be determined from the test configuration file; according to the determined positioning rule, the web page element corresponding to the interactive object specified by the test instruction is determined in the first web page. For another example, according to the test instruction and the positioning rule generation interface in the UI framework program module, the positioning rule of the interactive object specified by the test instruction is generated; according to the positioning rule, the web page element corresponding to the interactive object specified by the test instruction is determined in the first web page.

[0090] It should be noted that the web page element corresponding to the interactive object includes the UI component corresponding to the web page element, and the UI component corresponding to the web page element may include the UI component corresponding to the interactive object. Similarly, the UI component object corresponding to the web page element may also include the UI component object corresponding to the interactive object.

[0091] In order to quickly find a web page element for testing from the first web page, in one embodiment, generating a UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes:

[0092] Determine, according to at least one of the test instruction and the UI framework program module, a positioning rule for the interactive object specified by the test instruction;

[0093] Determining a web page element in the first web page according to the positioning rule;

[0094] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0095] Here, in the case of obtaining the test instruction and the UI framework program module corresponding to the front-end UI framework used by the first webpage, the positioning rule of the interactive object specified by the test instruction can be determined according to the test instruction, or the positioning rule of the interactive object specified by the test instruction can be determined according to the test instruction and the UI framework program module corresponding to the front-end UI framework used by the first webpage; according to the positioning rule of the interactive object specified by the test instruction, within the entire page range of the first webpage or within the page area range specified by the test instruction, the webpage element that meets the positioning rule of the interactive object is searched, that is, the webpage element corresponding to the interactive object is searched; in the case of finding the webpage element that meets the positioning rule of the interactive object, according to the test instruction and the UI framework program module, the UI component object corresponding to the webpage element is generated. An interactive object can correspond to multiple positioning rules and multiple webpage elements. In actual application, the webpage element that meets the positioning rule of the interactive object can be searched by calling the UI test tool (such as Selenium) interface. In addition, before searching for the webpage element that meets the positioning rule of the interactive object, invalid and interfering webpage elements, such as invisible webpage elements, can also be excluded first to improve the efficiency of searching for the webpage element that meets the positioning rule of the interactive object.

[0096] In order to improve the efficiency of determining web page elements, in one embodiment, determining the web page elements in the first web page includes:

[0097] According to the positioning rule of the interactive object specified by the test instruction, the web page elements in the first web page are determined within the page area specified by the test instruction; the positioning rule is determined according to at least one of the test instruction and the UI framework program module.

[0098] Here, when the test instruction includes a page area range, according to the positioning rule of the interactive object specified in the test instruction, the web page element that meets the positioning rule of the interactive object is searched within the page area range specified in the test instruction in the first web page. It should be noted that when the test instruction does not include a page area range, the web page element that meets the positioning rule of the interactive object is searched in the entire first web page.

[0099] In one embodiment, determining the positioning rule of the interactive object specified by the test instruction according to at least one of the test instruction and the UI framework program module includes:

[0100] According to the interactive object specified by the test instruction, determining in the test configuration file a positioning rule for the interactive object specified by the test instruction; and / or

[0101] A positioning rule for the interactive object specified by the test instruction is generated according to a UI framework program module corresponding to the front-end UI framework used by the first page.

[0102] Here, the positioning rule of the interactive object specified by the test instruction includes a user-defined positioning rule and / or a positioning rule automatically generated according to the UI framework program module.

[0103] In the case where the test configuration file includes a user-defined positioning rule, the user-defined positioning rule can be found in the test configuration file according to the interaction object specified by the test instruction.

[0104] The process of automatically generating positioning rules based on the UI framework program module is as follows:

[0105] In the case where the first web page corresponds to multiple UI framework program modules, the UI framework program modules corresponding to the first web page are traversed, and the positioning rule generation interface in the UI framework program module is called to generate the positioning rule of the interactive object; in the case where the first web page corresponds to one UI framework program module, the positioning rule generation interface in the UI framework program module is called to generate the positioning rule of the interactive object. The way to generate the positioning rule of the interactive object can be to instantiate the template or method in the positioning rule generation interface according to the interactive object specified by the test instruction to obtain the positioning rule of the interactive object. One UI framework program module corresponds to one positioning rule generation interface; the positioning rule generation interface in the UI framework program module includes a set of templates or methods, which can be obtained by extracting the CSS style of the UI component in the corresponding front-end UI framework, the spatial position of the UI component in the display window (such as x, y, z axis), and the hierarchy of the HTML DOM node corresponding to the UI component and one or more features of the HTML DOM node attributes. For example, when the test instruction is "click to log in", the web page element corresponding to the interactive object "login" specified by the test instruction should have the characteristics of being clickable and the text containing "login". The HTML tags that meet the clickable feature include button, a and div. The feature of the text containing "login" can be represented by Xpath[text()="login"]. According to the above characteristics of the interactive object "login", the positioning rule xpath= / / button[text()="login"] can be generated.

[0106] It should be noted that, when different first web pages use different front-end UI frameworks, the positioning rules of the interactive objects specified by the same test instruction may be different.

[0107] In this embodiment, according to at least one of the test instructions and the UI framework program module, the positioning rules of the interactive objects specified by the test instructions can be automatically generated corresponding to the first web page, thereby enhancing the adaptability of the test code to page changes, avoiding the manual maintenance of a large number of CSS selectors, XPATH selectors and other positioning selectors, reducing the difficulty of test case writing, and making test cases easier to maintain; in addition, the test execution program can also be combined with other tools (such as the Python behave framework) so that testers can write test cases in a low-code manner close to natural language, reducing the skill requirements for testers.

[0108] In order to prevent the UI component object generated corresponding to the UI component inside the web page element in the first web page from being missed, resulting in inaccurate test results, in one embodiment, generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes:

[0109] Searching for a UI component corresponding to the first web page element according to a first DOM node where the first web page element in the first page is located;

[0110] In the case where the UI component corresponding to the first webpage element is searched, generating a UI component object corresponding to the first webpage element according to the test instruction and the UI framework program module; or

[0111] If the UI component corresponding to the first webpage element is not found and / or the first condition is not met, searching for the UI component corresponding to the second webpage element according to the second DOM node, the second DOM node being the parent node of the first DOM node, and the second webpage element being the webpage element corresponding to the second DOM node;

[0112] When the UI component corresponding to the second web page element is searched, a UI component object corresponding to the second web page element is generated according to the test instruction and the UI framework program module.

[0113] Here, the above steps are performed for each first web page element in the first web page, and the first web page element may be any web page element in the first web page. When the above steps are performed for the first time, the first web page element may be a web page element corresponding to the interactive object specified by the test instruction, and when the above steps are not performed for the first time, the first web page element may be an upper-level DOM node of the first DOM node where the web page element corresponding to the interactive object specified by the test instruction is located, and the upper-level DOM node of the first DOM node includes the parent node of the first DOM node, and may also include the upper-level node of the parent node of the first DOM node.

[0114] When the above steps are performed for the first time: the web page element corresponding to the interactive object specified by the test instruction can be used as the first web page element, the initial traversal times can be set to 0, and the following steps can be performed:

[0115] Step 1: Generate a first DOM tree with the first DOM node where the first webpage element is located as the root node;

[0116] Step 2: traverse the DOM nodes in the first DOM tree to search for UI components in the first DOM tree, that is, UI components corresponding to the first web page element, and add 1 to the traversal times; the method for searching for UI components in the first DOM tree can be built into the UI framework program module; the method for searching for UI components in the first DOM tree can be: in the process of traversing the DOM nodes in the first DOM tree, according to the properties and / or style of the UI components in the front-end UI framework used by the first web page, check and test the DOM nodes (such as testing the HTML tags and / or properties and / or styles of the DOM nodes) to determine whether the DOM nodes in the first DOM tree are UI components, for example, match the properties or styles of the UI components in the front-end UI framework used by the first web page with the properties or styles of the DOM nodes, and if they match, determine that the DOM node is a UI component; if the DOM node in the first DOM tree is a UI component, the DOM node is the UI component corresponding to the searched first web page element, and the first web page element can correspond to one or more UI components. If the UI component in the first DOM tree is searched, execute step 3; if the UI component in the first DOM tree is not searched, and / or if the first condition is not met, execute step 4.

[0117] It should be noted that the first condition may be that the maximum number of traversals is reached; one traversal is completed when all DOM nodes in the DOM tree are traversed, and the DOM tree may be the first DOM tree or the second DOM tree; the maximum number of traversals may be pre-set in the test execution program, or may be determined according to the first web page and / or the test case before testing the first web page.

[0118] Step 3: According to the test instruction, call the interface of converting the corresponding web page element to UI component object in the UI framework program module, generate the UI component object of the UI component corresponding to the first web page element, and generate corresponding UI component objects for all UI components searched in the first DOM tree to obtain the UI component object corresponding to the first web page element, that is, the UI component object corresponding to the web page element in the first web page.

[0119] Step 4: Generate a second DOM tree with the second DOM node, which is the parent node of the first DOM node, as the root node; traverse the DOM nodes in the second DOM tree, search for UI components in the second DOM tree, that is, UI components corresponding to the second web page element, and increase the traversal times by 1. The method for searching UI components in the second DOM tree is the same as the method for searching UI components in the first DOM tree. If the UI components in the second DOM tree are found, execute step 5; if the UI components in the second DOM tree are not found and / or the first condition is not met, execute step 6.

[0120] Step 5: According to the test instruction, call the interface of converting the corresponding web page element to UI component object in the UI framework program module, generate the UI component object of the UI component corresponding to the second web page element, and generate corresponding UI component objects for all UI components searched in the second DOM tree to obtain the UI component object corresponding to the second web page element, that is, the UI component object corresponding to the web page element in the first web page.

[0121] Step 6: Take the web page element corresponding to the parent node of the second DOM node as the first web page element, and the parent node of the second DOM node as the first DOM node, and execute the above steps 1 to 5 again until the UI component object corresponding to the web page element in the first web page is obtained or the traversal times is greater than or equal to the set threshold.

[0122] It should be noted that traversing the first DOM tree in step 2 and traversing the second DOM tree in step 4 can both be implemented by a traversal algorithm, and the traversal algorithm can be a depth-first algorithm, a breadth-first algorithm or other algorithms, which are not specifically limited here.

[0123] In order to improve the accuracy of generating UI component objects corresponding to web page elements, in one embodiment, generating UI component objects corresponding to web page elements includes:

[0124] Determine the identifier of the first interface according to the test instruction and the first relationship, wherein the first relationship at least includes a correspondence between the test instruction and the identifier of the interface for converting the web page element to the UI component object;

[0125] A first interface in a UI framework program module corresponding to a front-end UI framework used by the first page is called to generate a UI component object corresponding to a web page element in the first web page.

[0126] Here, since there is a corresponding relationship or mapping relationship between the test instruction and the identifier of the interface from the web page element to the UI component object, the first interface is the interface from the web page element to the UI component object, therefore, the identifier of the first interface can be determined according to the first relationship; since the web page element in the first web page is determined according to the positioning rule of the interactive object specified by the test instruction, that is, the web page element in the first web page is the web page element corresponding to the test instruction, therefore, the first interface in the UI framework program module can be called according to the identifier of the first interface corresponding to the test instruction to generate the UI component object corresponding to the web page element. The corresponding relationship between the test instruction and the identifier of the interface from the web page element to the UI component object can be the corresponding relationship between the interactive action specified by the test instruction and the identifier of the interface from the web page element to the UI component object. For example, in the case where the interactive action is "click", the identifier of the interface from the web page element to the UI component object corresponding to the interactive action is get_component; in the case where the interactive action is "input", the identifier of the interface from the web page element to the UI component object corresponding to the interactive action is get_input_component. The interface from the web page element to the UI component object can be understood as the UI component object generation interface, and the identifier of the interface from the web page element to the UI component object can be the interface name of the web page element to the UI component object.

[0127] In order to accurately execute the test instruction through the UI component object, in one embodiment, testing the first webpage according to the test instruction and the UI component object to obtain the test result includes:

[0128] According to the interactive action and / or interactive data specified by the test instruction, the second interface is called to test the first web page to obtain a test result; the second interface is a user-defined interface corresponding to the interactive action in the test configuration file, or a built-in interface of a UI component object corresponding to a web page element in the first web page.

[0129] Here, the second interface can be determined according to the following rules:

[0130] According to the interactive action specified by the test instruction, find out whether there is a user-defined interface that implements the interactive action in the test configuration file; if there is a user-defined interface that implements the interactive action, use the user-defined interface as the second interface; if there is no user-defined interface that implements the interactive action, use the interface corresponding to the interactive action built into the UI component object corresponding to the web page element in the first web page as the second interface; call the second interface to test the first web page to obtain the test result. There is a one-to-one correspondence between the interactive action and the second interface, for example, the interactive action "click" corresponds to the interface click(), the interactive action "double-click" corresponds to the interface double_click(), and the interactive action "input" corresponds to the interface input(). The test instruction may include interactive data or may not include interactive data. For example, in the case where the interactive action is click or double-click, the test instruction may not include interactive data. In the case where the interactive action is input, the test instruction may include interactive data. The interactive data can be used as a parameter of the second interface to indicate the content input at the corresponding position of the web page element in the first web page.

[0131] It should be noted that calling the user-defined interface or the second interface to test the first webpage is achieved by calling the interface of a UI automation testing tool (such as Selenium) through the user-defined interface or the second interface.

[0132] In one embodiment, testing the first webpage according to the test instruction and the UI component object to obtain a test result includes:

[0133] Determine, among UI component objects corresponding to web page elements in the first web page, a UI component object corresponding to the interactive object specified by the test instruction;

[0134] According to the UI component object corresponding to the interactive object specified by the test instruction, the interactive action and / or interactive data specified by the test instruction, call the third interface to test the first web page to obtain the test result; the third interface is the user-defined interface corresponding to the interactive action in the test configuration file, or the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction.

[0135] Here, since the UI component objects corresponding to the web page elements in the first web page generated according to the test instruction and the UI framework program module include UI component objects corresponding to all UI components in the web page elements of the first web page, among which there may be UI component objects unrelated to the interactive objects specified by the test instruction, it is necessary to determine the UI component objects corresponding to the interactive objects specified by the test instruction from the UI component objects corresponding to the web page elements in the first web page, so that the first web page can be tested according to the UI component objects corresponding to the interactive objects specified by the test instruction, and the interactive actions and / or interactive data specified by the test instruction, by calling the third interface built into the UI component objects corresponding to the interactive objects specified by the test instruction to obtain the test results. The UI component objects related to the interactive objects specified by the test instruction can be determined more accurately, and there is no need to test the UI component objects unrelated to the interactive objects specified by the test instruction, thereby improving the test efficiency.

[0136] The third interface can be determined according to the following rules:

[0137] According to the interactive action specified by the test instruction, search in the test configuration file whether there is a user-defined interface that implements the interactive action; if there is a user-defined interface that implements the interactive action, use the user-defined interface as the third interface; if there is no user-defined interface that implements the interactive action, use the interface corresponding to the interactive action built into the UI component object corresponding to the interactive object specified by the test instruction as the third interface; call the third interface to test the first web page to obtain the test result.

[0138] In order to accurately determine the UI component object corresponding to the interactive object, so as to make the test result more accurate, in one embodiment, before determining the UI component object corresponding to the interactive object specified by the test instruction among the UI component objects corresponding to the web page elements in the first web page, the method further includes:

[0139] Determine a first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, wherein the first list at least includes text related to the web page element and / or an identifier of a UI component object corresponding to the web page element;

[0140] According to the text contained in the first list and the identifier of the interactive object specified by the test instruction, the identifier of the UI component object corresponding to the interactive object is determined in the first list.

[0141] Here, when determining the first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, the text related to the web page element in the first web page and the UI component corresponding to the web page element in the first web page can be searched, and the corresponding UI component object can be generated; the searched text related to the web page element and / or the identifier of the generated UI component object corresponding to the web page element are added to the first list. The parent node corresponding to the DOM node where the web page element in the first web page is located can include: the parent node of the DOM node where the web page element in the first web page is located, the parent node of the parent node of the DOM node where the web page element in the first web page is located; and so on, until the first list is determined.

[0142] In the case where the first list contains text related to the web page element, the identifier of the UI component object corresponding to the interactive object is determined in the first list based on the text contained in the first list and the identifier of the interactive object specified by the test instruction. Specifically, the first list can be traversed to search whether there is text related to the web page element that matches the identifier of the interactive object specified by the test instruction in the first list; in the case where there is text related to the web page element that matches the identifier of the interactive object specified by the test instruction in the first list, the UI component object corresponding to the adjacent or subordinate UI component of the DOM node corresponding to the text related to the matching web page element is determined as the UI component object corresponding to the interactive object, and the identifier of the UI component object is determined as the identifier of the UI component object corresponding to the interactive object; in the case where there is no text related to the web page element that matches the identifier of the interactive object specified by the test instruction in the first list, the identifiers of the UI component objects corresponding to all the web page elements in the first list are determined as the identifiers of the UI component objects corresponding to the interactive object.

[0143] It should be noted that the role of text is similar to a separator, so as to extract or determine the UI component object to be tested (the UI component object corresponding to the interactive object) from multiple UI component objects; the DOM node where the UI component corresponding to the UI component object corresponding to the interactive object is located may be a sibling node or a child node of the text.

[0144] In one embodiment, determining the first list according to the DOM node where the webpage element in the first webpage is located and / or the corresponding parent node includes:

[0145] Searching for text and a corresponding UI component of the first webpage element according to the first DOM node where the first webpage element is located;

[0146] When the text of the first webpage element and / or the corresponding UI component is found, the text of the first webpage element and / or the identifier of the corresponding UI component object is written into the first list; or

[0147] If the text and / or the corresponding UI component of the first web page element are not found, searching for the text and the corresponding UI component of the second web page element according to the second DOM node; the second DOM node is the parent node of the first DOM node, and the second web page element is the web page element corresponding to the second DOM node;

[0148] When the text of the second webpage element and / or the corresponding UI component are found in the search, the text of the second webpage element and / or the identifier of the corresponding UI component object are written into the first list.

[0149] Here, it is similar to the above method of generating UI component objects corresponding to web page elements in the first web page according to the test instructions and the UI framework program module; the difference is that: while searching for the UI components corresponding to the web page elements, the text related to the web page elements can be searched, and the text related to the web page elements and the identifier of the generated UI component object corresponding to the web page elements can be written into the first list.

[0150] Specifically, the above steps are performed for each first web page element in the first web page, and the first web page element may be any web page element in the first web page. When the above steps are performed for the first time, the first web page element may be a web page element corresponding to the interactive object specified by the test instruction, and when the above steps are not performed for the first time, the first web page element may be an upper-level DOM node of the first DOM node where the web page element corresponding to the interactive object specified by the test instruction is located, and the upper-level DOM node of the first DOM node includes the parent node of the first DOM node, and may also include the upper-level node of the parent node of the first DOM node.

[0151] When the above steps are performed for the first time: the web page element corresponding to the interactive object can be used as the first web page element, the initial traversal times can be set to 0, and the following steps can be performed to traverse the DOM tree and write the identifier of the UI component object corresponding to the web page element and the text related to the web page element into the first list:

[0152] A first DOM tree is generated with a first DOM node where a first web page element is located as a root node; DOM nodes in the first DOM tree are traversed, and the number of traversals is increased by 1; UI components in the first DOM tree are searched, and text nodes in the first DOM tree are searched. The UI components in the first DOM tree can be understood as UI components corresponding to the first web page element, and the text nodes in the first DOM tree can be understood as text related to the web page element; the method for searching the UI components in the first DOM tree can be: in the process of traversing the DOM nodes in the first DOM tree, according to the properties and / or style and other features of the UI components in the front-end UI framework used by the first web page, whether the DOM nodes in the first DOM tree are UI components; the method for searching the text nodes in the first DOM tree can be: in the process of traversing the DOM nodes in the first DOM tree, it is determined whether there are text nodes in the first DOM tree and the text content is not empty; if there are text nodes in the first DOM tree and the text content is not empty, the texts in all text nodes in the first DOM tree whose text content is not empty are written into the first list.

[0153] When the UI component corresponding to the first web page element is searched in the first DOM tree, the interface for converting the corresponding web page element to the UI component object in the UI framework program module is called according to the test instruction to generate UI component objects of all UI components corresponding to the first web page element, and the identifiers of the UI component objects of all UI components are written into the first list.

[0154] In the case where the UI component corresponding to the first web page element is not found in the first DOM tree, since the first DOM tree has been traversed and there may be text nodes in the first DOM tree, that is, there may be text related to the web page element in the first list, and the first list is not empty, it is necessary to first clear the first list, and then generate a second DOM tree with the parent node of the first DOM node (the second DOM node) as the root node; traverse the DOM nodes in the second DOM tree, search for the UI component in the second DOM tree (the UI component corresponding to the second web page element), and search for the text nodes in the first DOM tree (the text related to the web page element), and increase the number of traversals by 1; the method for searching the UI component in the second DOM tree is the same as the method for searching the UI component in the first DOM tree; the method for searching the text nodes in the second DOM tree is the same as the method for searching the text nodes in the first DOM tree; in the case where there are text nodes in the second DOM tree and the text content is not empty, write the text in all the text nodes whose text content is not empty in the second DOM tree into the first list. When the UI component corresponding to the second web page element is searched in the second DOM tree, the interface for converting the corresponding web page element to the UI component object in the UI framework program module is called according to the test instruction to generate UI component objects of all UI components corresponding to the second web page element, and the identifiers of the UI component objects of all UI components are written into the first list.

[0155] If the UI component corresponding to the first web page element is not found in the second DOM tree, the web page element corresponding to the parent node of the second DOM node is used as the first web page element, and the parent node of the second DOM node is used as the first DOM node, and the above steps of traversing the DOM tree and writing the identifier of the UI component object corresponding to the web page element and the text related to the web page element into the first list are performed again, until the first list including at least the text related to the web page element and / or the identifier of the UI component object corresponding to the web page element is obtained or the number of traversals is greater than or equal to the set threshold. The traversal algorithm can be a depth-first algorithm, a breadth-first algorithm or other algorithms, which are not specifically limited here.

[0156] It should be noted that the UI component is considered as a leaf node in the traversal algorithm; when the traversal algorithm is a depth-first algorithm, the first list may also include a depth value.

[0157] Taking the depth-first algorithm as an example, the specific steps for traversing a DOM tree are as follows:

[0158] Step 1: Starting from the root node of the DOM tree, traverse the DOM nodes in the DOM tree in combination with the adjacency list until the currently traversed node is a leaf node.

[0159] Step 2: Determine whether there are any untraversed DOM nodes in the adjacency list of the parent node of the currently traversed node; if there are no untraversed DOM nodes and the DOM tree has not been traversed, the parent node of the currently traversed node is used as the currently traversed node, the search depth value is reduced by 1, and step 2 is repeated; if there are any untraversed DOM nodes, step 3 is executed.

[0160] Step 3: Starting from the first untraversed DOM node in the adjacency list of the parent node of the currently traversed node, traverse the DOM nodes along the left side of the DOM tree in combination with the adjacency list until the currently traversed node is a leaf node. Repeat step 2 until the DOM tree traversal is complete.

[0161] Among them, the specific process of traversing the DOM nodes in the DOM tree is as follows Figure 3 As shown:

[0162] Step 301: Generate a first adjacency list with the third DOM node as the first node of the adjacency list.

[0163] Here, in the above step 1, the root node of the DOM tree is the third node; in the above step 3, in the adjacency list of the parent node of the currently traversed node, the first DOM node that has not been traversed is the third node.

[0164] Step 302: Determine whether the third DOM node is a UI component.

[0165] Here, the attributes and / or style of the UI component in the front-end UI framework used by the first web page can be matched with the attributes and / or style of the third DOM node; if the two match, the third DOM node is determined to be a UI component, and step 303 is executed; if the two do not match, the third DOM node is determined not to be a UI component, and step 304 is executed.

[0166] Step 303: Generate a UI component object corresponding to the third DOM node, and record the identifier of the UI component object into the first list.

[0167] Here, according to the test instruction, the corresponding web page element to UI component object interface in the UI framework program module can be called to generate a UI component object corresponding to the third DOM node, and the identifier of the UI component object corresponding to the third DOM node can be written into the first list.

[0168] Step 304: Determine whether the third DOM node is the end of the first adjacency list.

[0169] Here, when the third DOM node is at the end of the first adjacency list, step 307 is executed; when the third DOM node is not at the end of the first adjacency list, step 305 is executed.

[0170] Step 305: taking the next adjacent DOM node of the third DOM node as the third DOM node.

[0171] Here, the next adjacent DOM node of the third DOM node in the first adjacent list is taken as the third DOM node.

[0172] Step 306: The search depth value is increased by 1.

[0173] Here, after the search depth value is increased by 1, step 301 is executed, that is, the first adjacency list is generated with the third DOM node as the first node of the adjacency list.

[0174] Step 307: Determine whether the third DOM node is a text node and the text content is not empty.

[0175] Here, if the third DOM node is a text node and the text content is not empty, step 308 is executed; if the third DOM node is not a text node, or the third DOM node is a text node and the text content is empty, step 309 is executed.

[0176] Step 308: Write the text in the text node and the corresponding search depth value into the first list.

[0177] Here, the text in the text node corresponding to the third DOM node and the search depth value corresponding to the third DOM node are written into the first list.

[0178] Step 309: End the current search.

[0179] Here, when a UI component object corresponding to the third DOM node is generated and the identifier of the UI component object is recorded in the first list, the current search is ended; or when the third DOM node is at the end of the first adjacency list and the text content of the third DOM node and the search depth value corresponding to the third DOM node are written into the first list, the current search is ended.

[0180] For example, the test instruction is "Enter activity name = automated demonstration", the traversal algorithm is the depth-first algorithm, the starting search depth value is 0, and the HTML source code snippet corresponding to the interactive object activity name is as follows Figure 4 As shown, the web page element corresponding to the interactive object "activity name" is used as the root node to generate a first DOM tree, and the element nodes in the first DOM tree are numbered with letters, and the node number of the root node is A. The first DOM tree is as follows Figure 5As shown, the condition for judging whether a DOM node in the DOM tree is a UI component is that the class attribute value of the DOM node is el-input, that is, in the UI component corresponding to the front-end UI framework used by the first webpage, the attribute characteristic of the input class component is that the attribute value of the class attribute is el-input. Figure 5 As an example, the first DOM tree in Figure 3 The traversal process in traverses the first DOM tree and determines the steps of the first list as follows:

[0181] Step 1: Take the first DOM node, i.e., node A, as the third DOM node, and take the third DOM node as the first in the adjacency list to generate the first adjacency list A->B->C (corresponding to Figure 3 (step 301 in the example above).

[0182] Step 2: Determine whether node A is a UI component (corresponding to Figure 3 Specifically, it is determined whether the attribute of node A matches the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage. The attribute value of the class attribute of node A is el-form-item, and the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage are that the attribute value of the class attribute is el-input. The two do not match, and node A is not a UI component.

[0183] Step 3: Determine whether node A is at the end of the first adjacency list (corresponding to Figure 3 Since the first adjacency list corresponding to node A is A->B->C, node A is not at the end of the first adjacency list.

[0184] Step 4: Set the next adjacent DOM node of node A as the third DOM node (corresponding to Figure 3 In step 305). In the first adjacency list A->B->C, the next adjacent DOM node of node A is node B, and node B is used as the third DOM node.

[0185] Step 5: Search depth value plus 1 (corresponding to Figure 3 The search depth value is changed from the initial search depth value 0 to 1.

[0186] Step 6: Generate the first adjacency table B->activity name (corresponding to Figure 3 (step 301 in the example above).

[0187] Step 7: Determine whether node B is a UI component (corresponding to Figure 3Specifically, it is determined whether the attribute of node B matches the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage. The attribute value of the class attribute of node B is el-form-item_label. The two also do not match, and node B is not a UI component.

[0188] Step 8: Determine whether node B is at the end of the first adjacency list (corresponding to Figure 3 Since the first adjacency list corresponding to node B is B->activity name, node B is not at the end of the first adjacency list.

[0189] Step 9: Set the next adjacent DOM node of node B as the third DOM node (corresponding to Figure 3 In step 305), in the first adjacency list B->activity name, the next adjacent DOM node of node B is the text node activity name, and the activity name is used as the third DOM node.

[0190] Step 10: Search depth value plus 1 (corresponding to Figure 3 The search depth value is changed from the search depth value 1 to 2.

[0191] Step 11: Generate the first adjacency table activity name (corresponding to Figure 3 In step 301), since the activity name has no child nodes, the activity name is used as the first node of the adjacency list, and the first adjacency list generated contains only the text node activity name.

[0192] Step 12: Determine whether the activity name is a UI component (corresponding to Figure 3 Step 302). The activity name is a text node, not a UI component.

[0193] Step 13: Determine whether the activity name is at the end of the first adjacency list (corresponding to Figure 3 Since the first adjacency list corresponding to the activity name is the activity name, the activity name is at the end of the first adjacency list.

[0194] Step 14: Determine whether the activity name is a text node (corresponding to Figure 3 (Step 307). The activity name is a text node, and the text content is not empty.

[0195] Step 15: Write the text in the text node and the corresponding search depth value into the first list (corresponding to Figure 3 In step 308). The text in the text node is "activity name", and the search depth value at this time is 2, and (2, "activity name") is written into the first list.

[0196] Step 16: End the current search (corresponding to Figure 3In step 309), the currently traversed node is the activity name; determine whether there are any untraversed DOM nodes in the adjacency list (B->activity name) of the parent node (node ​​B) of the activity name; it can be seen that all DOM nodes in the adjacency list of node B have been traversed, and there are no untraversed DOM nodes.

[0197] Step 17: Set the parent node (node ​​B) of the currently traversed node (activity name) as the currently traversed node, and reduce the search depth value by 1, that is, the search depth value changes from 2 to 1.

[0198] Step 18: Determine whether there are any untraversed DOM nodes in the adjacency list (A->B->C) of the parent node (node ​​A) of node B; it can be seen that there is an untraversed node C in the adjacency list of node A.

[0199] Step 19: Take node C as the third DOM node and the third DOM node as the first node of the adjacency list to generate the first adjacency list C->D (corresponding to Figure 3 (step 301 in the example above).

[0200] Step 20: Determine whether node C is a UI component (corresponding to Figure 3 Specifically, it is determined whether the attribute of node C matches the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage. The attribute value of the class attribute of node C is el-form-item_content. The two also do not match, and node C is not a UI component.

[0201] Step 21: Determine whether node C is at the end of the first adjacency list (corresponding to Figure 3 Since the first adjacency list corresponding to node C is C->D, node C is not at the end of the first adjacency list.

[0202] Step 22: Set the next adjacent DOM node of node C as the third DOM node (corresponding to Figure 3 In step 305). In the first adjacency list C->D, the next adjacent DOM node of node C is node D, and node D is used as the third DOM node.

[0203] Step 23: Search depth value plus 1 (corresponding to Figure 3 The search depth value is changed from the search depth value 1 to 2.

[0204] Step 24: With node D as the first node of the adjacency list, generate the first adjacency list D->E (corresponding to Figure 3 (step 301 in the example above).

[0205] Step 25: Determine whether node D is a UI component (corresponding to Figure 3Specifically, it is determined whether the attribute of node D matches the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage, the attribute value of the class attribute of node D is el-input, which matches the attribute characteristics of the UI component corresponding to the front-end UI framework used by the first webpage, and node D is a UI component.

[0206] Step 26: Generate a UI component object corresponding to node D, and record the identifier of the UI component object in the first list (corresponding to Figure 3 The method for generating the UI component object corresponding to the node D is: calling the interface of converting the web page element to the UI component object corresponding to the interactive action "input" specified by the test instruction in the UI framework program module to generate the UI component object corresponding to the node D.

[0207] Step 27: End the current search (corresponding to Figure 3 In step 309), the currently traversed node is node D; it is determined whether there are any untraversed DOM nodes in the adjacency list (C->D) of the parent node (node ​​C) of node D; it can be seen that all DOM nodes in the adjacency list of node C have been traversed, and there are no untraversed DOM nodes.

[0208] Step 28: Take the parent node (node ​​C) of the currently traversed node (node ​​D) as the currently traversed node, and reduce the search depth value by 1, that is, the search depth value changes from 2 to 1.

[0209] Step 29: Determine whether there are any untraversed DOM nodes in the adjacency list (A->B->C) of the parent node (node ​​A) of node C; it can be seen that all DOM nodes in the adjacency list of node A have been traversed, and there are no untraversed DOM nodes, and the first DOM tree traversal is completed.

[0210] The present application is further described in detail below with reference to application examples. Figure 6 shown.

[0211] Step 601: Determine test instructions according to the test case.

[0212] For the specific implementation process of step 601, please refer to the relevant description above and will not be repeated here.

[0213] Step 602: Determine the UI framework program module corresponding to the front-end UI framework used by the first webpage in the test execution program.

[0214] Here, the first webpage may correspond to a plurality of UI framework program modules. In actual applications, the first webpage may correspond to a UI framework program module list, and the UI framework program module list includes one or more UI framework program modules corresponding to the first webpage.

[0215] Step 603: Determine a positioning rule of the interactive object specified by the test instruction according to at least one of the test instruction and the UI framework program module.

[0216] Here, the positioning rules of the interactive object specified by the test instruction can be determined based on the test instruction and the list of UI framework program modules corresponding to the first web page; an interactive object can correspond to multiple positioning rules. In actual applications, an interactive object can correspond to a positioning rule list, and the positioning rule list contains one or more positioning rules corresponding to the interactive object.

[0217] Step 604: Determine a web page element in the first web page according to the positioning rule.

[0218] Here, by traversing the positioning rule list corresponding to the interactive object, the web page element that satisfies at least one positioning rule in the positioning rule list can be determined in the first web page to obtain the web page element corresponding to the interactive object; there may be multiple web page elements determined in the first web page, that is, one interactive object can correspond to one or more web page elements. In actual applications, one interactive object can correspond to a web page element list, and the web page element list contains one or more web page elements corresponding to the interactive object.

[0219] Step 605: Generate a UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module.

[0220] Here, for each web page element in the web page element list corresponding to the interactive object, a UI component object corresponding to the web page element is generated according to the test instruction and the UI framework program module. There may be multiple UI components in a web page element, and multiple UI component objects can be generated accordingly. In actual applications, a web page element can correspond to a UI component object list, and the UI component object list contains one or more UI component objects corresponding to the web page element.

[0221] Step 606: Determine, among the UI component objects corresponding to the web page elements in the first web page, the UI component object corresponding to the interactive object specified by the test instruction.

[0222] Here, the UI component object corresponding to the interactive object may be determined from the UI component objects corresponding to each web page element in the list of web page elements corresponding to the interactive object.

[0223] Step 607: According to the interactive action and / or interactive data specified by the test instruction, call the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction, test the first webpage, and obtain the test result.

[0224] For the specific implementation process of step 607, please refer to the relevant description above and will not be repeated here.

[0225] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a web page testing device, such as Figure 7 As shown, the device comprises:

[0226] The first determining unit 701 is used to determine the UI framework program module corresponding to the front-end UI framework used by the first webpage in the test execution program;

[0227] A generating unit 702, configured to generate a UI component object corresponding to a web page element in the first web page according to a test instruction and the UI framework program module;

[0228] The testing unit 703 is used to test the first webpage according to the test instruction and the UI component object to obtain a test result.

[0229] In one embodiment, the generating unit 702 is specifically configured to determine a web page element in the first web page according to at least one of the test instruction and the UI framework program module;

[0230] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0231] In one embodiment, the generating unit 702 is specifically configured to determine a positioning rule of the interactive object specified by the test instruction according to at least one of the test instruction and the UI framework program module;

[0232] Determining a web page element in the first web page according to the positioning rule;

[0233] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0234] In one embodiment, the generating unit 702 is specifically configured to determine, in the test configuration file, a positioning rule of the interactive object specified by the test instruction according to the interactive object specified by the test instruction; and / or

[0235] A positioning rule for the interactive object specified by the test instruction is generated according to a UI framework program module corresponding to the front-end UI framework used by the first page.

[0236] In one embodiment, the generating unit 702 is specifically used to determine the web page elements in the first web page within the page area specified by the test instruction according to the positioning rule of the interactive object specified by the test instruction; the positioning rule is determined according to at least one of the test instruction and the UI framework program module.

[0237] In one embodiment, the generating unit 702 is specifically configured to search for a UI component corresponding to the first web page element according to the first DOM node where the first web page element in the first page is located;

[0238] In the case where the UI component corresponding to the first webpage element is searched, generating a UI component object corresponding to the first webpage element according to the test instruction and the UI framework program module; or

[0239] If the UI component corresponding to the first webpage element is not found and / or the first condition is not met, searching for the UI component corresponding to the second webpage element according to the second DOM node, the second DOM node being the parent node of the first DOM node, and the second webpage element being the webpage element corresponding to the second DOM node;

[0240] When the UI component corresponding to the second web page element is searched, a UI component object corresponding to the second web page element is generated according to the test instruction and the UI framework program module.

[0241] In one embodiment, the generating unit 702 is specifically configured to determine the identifier of the first interface according to the test instruction and the first relationship, wherein the first relationship at least includes a corresponding relationship between the test instruction and the identifier of the interface for converting the web page element to the UI component object;

[0242] A first interface in a UI framework program module corresponding to a front-end UI framework used by the first page is called to generate a UI component object corresponding to a web page element in the first web page.

[0243] In one embodiment, the testing unit 703 is specifically used to call the second interface to test the first web page according to the interactive action and / or interactive data specified by the test instruction to obtain a test result; the second interface is a user-defined interface corresponding to the interactive action in the test configuration file, or an interface built into the UI component object corresponding to the web page element in the first web page.

[0244] In one embodiment, the testing unit 703 is specifically configured to determine, among UI component objects corresponding to web page elements in the first web page, a UI component object corresponding to the interactive object specified by the testing instruction;

[0245] According to the UI component object corresponding to the interactive object specified by the test instruction, the interactive action and / or interactive data specified by the test instruction, call the third interface to test the first web page to obtain the test result; the third interface is the user-defined interface corresponding to the interactive action in the test configuration file, or the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction.

[0246] In one embodiment, the device further comprises:

[0247] A second determining unit is used to determine a first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, wherein the first list at least includes text related to the web page element and / or an identifier of a UI component object corresponding to the web page element;

[0248] The third determining unit is used to determine the identifier of the UI component object corresponding to the interactive object in the first list according to the text contained in the first list and the identifier of the interactive object specified by the test instruction.

[0249] In one embodiment, the second determining unit is specifically configured to search for the text of the first web page element and the corresponding UI component according to the first DOM node where the first web page element is located;

[0250] When the text of the first webpage element and / or the corresponding UI component is found, the text of the first webpage element and / or the identifier of the corresponding UI component object is written into the first list; or

[0251] If the text and / or the corresponding UI component of the first web page element are not found, searching for the text and the corresponding UI component of the second web page element according to the second DOM node; the second DOM node is the parent node of the first DOM node, and the second web page element is the web page element corresponding to the second DOM node;

[0252] When the text of the second webpage element and / or the corresponding UI component are found in the search, the text of the second webpage element and / or the identifier of the corresponding UI component object are written into the first list.

[0253] In one embodiment, the device further comprises:

[0254] The fourth determining unit is used to determine the test instruction according to the test case.

[0255] In actual application, the first determination unit 701, the generation unit 702, the testing unit 703, the second determination unit, the third determination unit and the fourth determination unit may be implemented by a processor in the web page testing device.

[0256] It should be noted that: the above embodiment provides a web page testing device, and only uses the division of the above program modules as an example to illustrate when performing web page testing. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the above-described processing. In addition, the web page testing device provided in the above embodiment and the web page testing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0257] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device, such as Figure 8 As shown, the electronic device 800 includes:

[0258] The communication interface 801 is used to exchange information with other network nodes.

[0259] The processor 802 is used to connect to the communication interface 801 to implement information interaction with other network nodes, and is used to execute the methods provided by one or more technical solutions of the above embodiments when running a computer program.

[0260] The memory 803 is used to store computer programs that can be executed on the processor 802 .

[0261] Specifically, the processor 802 is used to determine the UI framework program module corresponding to the front-end UI framework used by the first web page in the test execution program; generate the UI component object corresponding to the web page element in the first web page according to the test instructions and the UI framework program module; test the first web page according to the test instructions and the UI component object to obtain the test results.

[0262] In one embodiment, the processor 802 is specifically configured to determine a web page element in the first web page according to at least one of the test instruction and the UI framework program module;

[0263] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0264] In one embodiment, the processor 802 is specifically configured to determine a positioning rule of the interactive object specified by the test instruction according to at least one of the test instruction and the UI framework program module;

[0265] Determining a web page element in the first web page according to the positioning rule;

[0266] According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

[0267] In one embodiment, the processor 802 is specifically configured to determine, in a test configuration file, a positioning rule of the interactive object specified by the test instruction according to the interactive object specified by the test instruction; and / or

[0268] A positioning rule for the interactive object specified by the test instruction is generated according to a UI framework program module corresponding to the front-end UI framework used by the first page.

[0269] In one embodiment, the processor 802 is specifically used to determine the web page elements in the first web page within the page area specified by the test instruction according to the positioning rule of the interactive object specified by the test instruction; the positioning rule is determined according to the test instruction and at least one of the UI framework program module.

[0270] In one embodiment, the processor 802 is specifically configured to search for a UI component corresponding to the first web page element according to a first DOM node where the first web page element in the first page is located;

[0271] In the case where the UI component corresponding to the first webpage element is searched, generating a UI component object corresponding to the first webpage element according to the test instruction and the UI framework program module; or

[0272] If the UI component corresponding to the first webpage element is not found and / or the first condition is not met, searching for the UI component corresponding to the second webpage element according to the second DOM node, the second DOM node being the parent node of the first DOM node, and the second webpage element being the webpage element corresponding to the second DOM node;

[0273] When the UI component corresponding to the second web page element is searched, a UI component object corresponding to the second web page element is generated according to the test instruction and the UI framework program module.

[0274] In one embodiment, the processor 802 is specifically configured to determine an identifier of a first interface according to the test instruction and a first relationship, wherein the first relationship at least includes a correspondence between the test instruction and an identifier of an interface for converting a web page element to a UI component object;

[0275] A first interface in a UI framework program module corresponding to a front-end UI framework used by the first page is called to generate a UI component object corresponding to a web page element in the first web page.

[0276] In one embodiment, the processor 802 is specifically used to call the second interface to test the first web page according to the interactive action and / or interactive data specified by the test instruction to obtain a test result; the second interface is a user-defined interface corresponding to the interactive action in the test configuration file, or an interface built into the UI component object corresponding to the web page element in the first web page.

[0277] In one embodiment, the processor 802 is specifically configured to determine, among UI component objects corresponding to web page elements in the first web page, a UI component object corresponding to the interactive object specified by the test instruction;

[0278] According to the UI component object corresponding to the interactive object specified by the test instruction, the interactive action and / or interactive data specified by the test instruction, call the third interface to test the first web page to obtain the test result; the third interface is the user-defined interface corresponding to the interactive action in the test configuration file, or the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction.

[0279] In one embodiment, the processor 802 is further configured to determine a first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, wherein the first list at least includes text related to the web page element and / or an identifier of a UI component object corresponding to the web page element;

[0280] According to the text contained in the first list and the identifier of the interactive object specified by the test instruction, the identifier of the UI component object corresponding to the interactive object is determined in the first list.

[0281] In one embodiment, the processor 802 is specifically configured to search for the text of the first web page element and the corresponding UI component according to the first DOM node where the first web page element is located;

[0282] When the text of the first webpage element and / or the corresponding UI component is found, the text of the first webpage element and / or the identifier of the corresponding UI component object is written into the first list; or

[0283] If the text and / or the corresponding UI component of the first web page element are not found, searching for the text and the corresponding UI component of the second web page element according to the second DOM node; the second DOM node is the parent node of the first DOM node, and the second web page element is the web page element corresponding to the second DOM node;

[0284] When the text of the second webpage element and / or the corresponding UI component are found in the search, the text of the second webpage element and / or the identifier of the corresponding UI component object are written into the first list.

[0285] In one embodiment, the processor 802 is further configured to determine the test instruction according to a test case.

[0286] It should be noted that the specific processing process of the processor 802 and the communication interface 801 can be understood by referring to the above method.

[0287] Of course, in actual application, the various components in the electronic device 800 are coupled together through the bus system 804. It can be understood that the bus system 804 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 804 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 8 Various buses are labeled as bus system 804 .

[0288] The memory 803 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device 800. Examples of such data include: any computer program used to operate on the electronic device 800.

[0289] The method disclosed in the above embodiment of the present application can be applied to the processor 802, or implemented by the processor 802. The processor 802 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 802. The above-mentioned processor 802 may be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 802 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 803, and the processor 802 reads the information in the memory 803 and completes the steps of the above method in combination with its hardware.

[0290] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0291] It can be understood that the memory (memory 803) of the embodiment of the present application can be a volatile memory or a non-volatile memory, and can also include both a volatile memory and a non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable types of memory.

[0292] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 803 storing a computer program, and the computer program can be executed by a processor 802 of an electronic device 800 to complete the steps described in the aforementioned embodiment. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.

[0293] Illustratively, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by a processor 802 of an electronic device 800 to complete the steps of any of the aforementioned methods.

[0294] It should be noted that “first”, “second”, etc. are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0295] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one of" or "at least one item" herein represents any combination of at least two of any one or more of a plurality of items. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.

[0296] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0297] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.

Claims

1. A web page testing method, It is characterized in that The method comprises: Determine a UI framework program module corresponding to the front-end user interface UI framework used by the first webpage in the test execution program; Generate a UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module; The first webpage is tested according to the test instruction and the UI component object to obtain a test result.

2. The method according to claim 1, It is characterized in that Generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes: Determine a web page element in the first web page according to at least one of the test instruction and the UI framework program module; According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

3. The method according to claim 1, It is characterized in that Generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes: Determine, according to at least one of the test instruction and the UI framework program module, a positioning rule for the interactive object specified by the test instruction; Determining a webpage element in the first webpage according to the positioning rule; According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated.

4. The method according to claim 3, It is characterized in that The determining, according to at least one of the test instruction and the UI framework program module, a positioning rule of the interactive object specified by the test instruction includes: According to the interactive object specified by the test instruction, determining in the test configuration file a positioning rule for the interactive object specified by the test instruction; and / or A positioning rule for the interactive object specified by the test instruction is generated according to a UI framework program module corresponding to the front-end UI framework used by the first page.

5. The method according to claim 2 or 3, It is characterized in that Determining the webpage element in the first webpage includes: According to the positioning rule of the interactive object specified by the test instruction, the web page elements in the first web page are determined within the page area specified by the test instruction; the positioning rule is determined according to at least one of the test instruction and the UI framework program module.

6. The method according to claim 1, It is characterized in that Generating the UI component object corresponding to the web page element in the first web page according to the test instruction and the UI framework program module includes: Searching for a UI component corresponding to the first web page element according to a first document object model DOM node where the first web page element in the first page is located; In the case where the UI component corresponding to the first webpage element is searched, generating a UI component object corresponding to the first webpage element according to the test instruction and the UI framework program module; or If the UI component corresponding to the first webpage element is not found and / or the first condition is not met, searching for the UI component corresponding to the second webpage element according to the second DOM node, the second DOM node being the parent node of the first DOM node, and the second webpage element being the webpage element corresponding to the second DOM node; When the UI component corresponding to the second web page element is searched, a UI component object corresponding to the second web page element is generated according to the test instruction and the UI framework program module.

7. The method according to any one of claims 1 to 3 and 6, It is characterized in that Generate UI component objects corresponding to web page elements, including: Determine the identifier of the first interface according to the test instruction and the first relationship, wherein the first relationship at least includes a correspondence between the test instruction and the identifier of the interface for converting the web page element to the UI component object; A first interface in a UI framework program module corresponding to a front-end UI framework used by the first page is called to generate a UI component object corresponding to a web page element in the first web page.

8. The method according to any one of claims 1 to 4 and 6, It is characterized in that The step of testing the first webpage according to the test instruction and the UI component object to obtain a test result includes: According to the interactive action and / or interactive data specified by the test instruction, the second interface is called to test the first web page to obtain a test result; the second interface is a user-defined interface corresponding to the interactive action in the test configuration file, or a built-in interface of a UI component object corresponding to a web page element in the first web page.

9. The method according to any one of claims 1 to 4 and 6, It is characterized in that The step of testing the first webpage according to the test instruction and the UI component object to obtain a test result includes: Determine, among UI component objects corresponding to web page elements in the first web page, a UI component object corresponding to the interactive object specified by the test instruction; According to the UI component object corresponding to the interactive object specified by the test instruction, the interactive action and / or interactive data specified by the test instruction, call the third interface to test the first web page to obtain the test result; the third interface is the user-defined interface corresponding to the interactive action in the test configuration file, or the built-in interface of the UI component object corresponding to the interactive object specified by the test instruction.

10. The method according to claim 9, It is characterized in that Before determining, among the UI component objects corresponding to the web page elements in the first web page, the UI component object corresponding to the interactive object specified by the test instruction, the method further includes: Determine a first list according to the DOM node where the web page element in the first web page is located and / or the corresponding parent node, wherein the first list at least includes text related to the web page element and / or an identifier of a UI component object corresponding to the web page element; According to the text contained in the first list and the identifier of the interactive object specified by the test instruction, the identifier of the UI component object corresponding to the interactive object is determined in the first list.

11. The method according to claim 10, It is characterized in that The determining of the first list according to the DOM node where the webpage element in the first webpage is located and / or the corresponding parent node includes: Searching for text and a corresponding UI component of the first webpage element according to the first DOM node where the first webpage element is located; When the text of the first webpage element and / or the corresponding UI component is found, the text of the first webpage element and / or the identifier of the corresponding UI component object is written into the first list; or If the text and / or the corresponding UI component of the first web page element are not found, searching for the text and the corresponding UI component of the second web page element according to the second DOM node; the second DOM node is the parent node of the first DOM node, and the second web page element is the web page element corresponding to the second DOM node; When the text of the second webpage element and / or the corresponding UI component are found in the search, the text of the second webpage element and / or the identifier of the corresponding UI component object are written into the first list.

12. The method according to any one of claims 1 to 4, 6, 10, 11, It is characterized in that The method further comprises: The test instruction is determined according to the test case.

13. A web page testing device, It is characterized in that include: A first determining unit, used to determine a UI framework program module corresponding to a front-end UI framework used by the first webpage in a test execution program; A generating unit, configured to generate a UI component object corresponding to a web page element in the first web page according to a test instruction and the UI framework program module; The testing unit is used to test the first webpage according to the testing instruction and the UI component object to obtain a testing result.

14. An electronic device, It is characterized in that include: Processor and communication interface; wherein, The processor is used to determine a UI framework program module corresponding to the front-end UI framework used by the first webpage in the test execution program; According to the test instruction and the UI framework program module, a UI component object corresponding to the web page element in the first web page is generated; according to the test instruction and the UI component object, the first web page is tested to obtain a test result.

15. An electronic device, It is characterized in that comprising a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 12.

16. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

17. A computer program product comprising a computer program, It is characterized in that The computer program implements the steps of the method according to any one of claims 1 to 12 when executed by a processor.