UI page testing method, device, equipment, storage medium and product
By personalizing naming and automatically positioning UI page tags, the problem of inefficient testing of traditional UI pages is solved, and efficient UI page testing and functional testing automation is achieved.
Patent Information
- Application Number
- CN202411260043.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-09-10
AI Technical Summary
Traditional UI page automation testing is inefficient, and tag elements need to be manually repositioned when page layout is updated, resulting in waste of resources.
By personalizing the UI page tags, and generating the initial tag name based on the preset naming specifications, determining the tag location and functional method categories, automated page functional testing is realized.
Improves the efficiency of UI page testing, reduces human resource waste, and realizes the automation of functional testing.
Smart Images

Figure CN118796709B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of front-end testing technology, and in particular to a UI page testing method, device, equipment, storage medium and product. Background Art
[0002] In traditional UI (User Interface) page automation testing, tag name positioning or tag hierarchy positioning is usually used to perform relative or absolute tag positioning. However, due to the single tag element of HTML (HyperText Markup Language) and the frequent modification of pages during the development process, the hierarchy of page tags changes, and the tag elements need to be manually repositioned, resulting in low efficiency of UI page testing and a large waste of tester resources. Summary of the invention
[0003] The present invention provides a UI page testing method, device, equipment, storage medium and product to improve UI page testing efficiency and reduce the waste of tester resources.
[0004] According to one aspect of the present invention, a UI page testing method is provided, the method comprising:
[0005] Perform tag recognition on the page tags in the user interface UI page to be tested to obtain the page tags to be processed;
[0006] According to the preset tag keywords, the tag of the page to be processed is subjected to keyword recognition to obtain the initial tag name of the tag of the page to be tested;
[0007] If the page tag to be tested is a personalized page tag, then according to the initial tag name of the page tag to be tested, the tag position of the page tag to be tested in the UI page to be tested is determined; the tag name of the personalized page tag is generated based on a preset naming specification;
[0008] Determining the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested;
[0009] According to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, a page function test is performed on the UI page to be tested, and a function test result is obtained.
[0010] According to another aspect of the present invention, a UI page testing device is provided, the device comprising:
[0011] The tag recognition module is used to identify the page tags in the user interface UI page to be tested and obtain the page tags to be processed;
[0012] A keyword recognition module, used to perform keyword recognition on the page tag to be processed according to preset tag keywords, and obtain an initial tag name of the page tag to be tested;
[0013] A tag position determination module, for determining the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested if the page tag to be tested is a personalized page tag; the tag name of the personalized page tag is generated based on a preset naming specification;
[0014] A method category determination module, used to determine the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested;
[0015] The function test module is used to perform page function test on the UI page to be tested according to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, and obtain the function test result.
[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the UI page testing method described in any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the UI page testing method described in any embodiment of the present invention when executed.
[0021] According to another aspect of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the UI page testing method according to any embodiment of the present invention.
[0022] The above technical solution sets personalized page tags, accurately locates based on the characteristics of personalized page tags, and parses personalized page tags to obtain corresponding function method categories, and performs automated testing of page functions according to the test categories corresponding to the function method categories, thereby improving the efficiency of UI page testing, and eliminating the need for testers to manually change tag names when updating page layouts, which wastes human resources. At the same time, the corresponding function method categories that are automatically located can determine the function method categories and their corresponding function test types without manual positioning, further realizing the automation of function testing and improving the efficiency of function testing.
[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 is a flowchart of a UI page testing method provided according to Embodiment 1 of the present invention;
[0026] Figure 2 is a flowchart of a UI page testing method provided according to Embodiment 2 of the present invention;
[0027] Figure 3 is a structural schematic diagram of a UI page testing device provided according to Embodiment 3 of the present invention;
[0028] Figure 4 It is a structural schematic diagram of an electronic device for implementing the UI page testing method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Embodiment 1
[0032] Figure 1 This is a flowchart of a UI page testing method provided in the first embodiment of the present invention. This embodiment is applicable to the case of performing automated testing on the front-end UI page. The method can be executed by a UI page testing device. The UI page testing device can be implemented in the form of hardware and / or software. The UI page testing device can be configured in an electronic device. Figure 1 As shown, the method includes:
[0033] S110 , performing tag recognition on page tags in the user interface UI page to be tested to obtain page tags to be processed.
[0034] S120 , performing keyword recognition on the page tag to be processed according to preset tag keywords to obtain an initial tag name of the page tag to be tested.
[0035] S130: If the page tag to be tested is a personalized page tag, determine the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested; the tag name of the personalized page tag is generated based on a preset naming specification.
[0036] S140: Determine the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested.
[0037] S150 , according to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, perform page function test on the UI page to be tested, and obtain the function test result.
[0038] It should be noted that since the page tag element name is single and the number of the same page tag elements referenced in the page may be multiple, if positioning is performed only based on the page tag name or the superior-subordinate relationship of the page tags during the positioning process, at least multiple page tags with the same name may be located. And when the page is updated, the superior-subordinate relationship between the page tag element and the element changes, so it is impossible to locate based on the initial superior-subordinate relationship, and relevant technical personnel need to manually update the positioning mark, resulting in low efficiency of UI automated testing and a waste of a lot of human resources.
[0039] Based on the above defects, this application gives personalized names to the page labels corresponding to the page function modules that need to be tested, and the specific naming method is pre-set by relevant technical personnel. Based on the test of the page function method, the function method corresponding to the page label can be introduced in the naming method, and based on the comprehensive consideration of the test authority, the name of the tester can be introduced in the naming method. Usually, the label elements corresponding to the function methods with functional testing requirements are personalized.
[0040] For example, for user login interface A, there is a text input box for inputting user name and password in the interface A, and the corresponding function call method is input() method, and the user name with function test permission is username, and the project abbreviation of the project to which the user login interface A belongs is hl. Therefore, the label name of the personalized label corresponding to the text input function test can be named as: hl-username-input. The following is an example of the use of the personalized label name in the front-end code:
[0041] <hl-username-input>
[0042] username:
[0043]
[0044] < / hl-username-input >
[0045] The page generation method including the personalized page tag can be specifically generated through Web Components. Web Components can create reusable custom elements (Custom Elements) and encapsulated components to generate personalized tags, i.e., custom tag elements, to obtain a UI page including the personalized page tag. The encapsulated components can be, for example, Shadow DOM (Document Object Model) and HTMLTemplates.
[0046] Perform tag identification or tag export on the page tags in the UI page to be tested to obtain the page tags to be processed. The tag identification method can be based on tag element symbols; the tag export method can be based on the tagName positioning method in selenium (automated testing tool) to locate the page tag elements. Specifically, the positioning method can be driver.findElements(By.tagName("*")). The tagName positioning method is used to obtain or set the attributes of the tag name, for example, The tag name of the element is "div". The tag name of the element is "a". The page tag to be processed is the page tag obtained after the page tag of the UI page to be tested is identified.
[0047] Among them, the preset tag keywords can be pre-set by relevant technical personnel according to the different functional testing requirements of the test items. For example, to locate the page tag containing "hl", the tag keyword is set to "hl" and the page tag containing "hl" is traversed or searched through the getText().contains("hl") method.
[0048] According to the preset tag keywords corresponding to different functional test requirements, the tag types of the page tags to be tested are different. Among them, the page tags to be tested may be personalized page tags or traditional page tags. The tag name of the traditional page tag is the original name of the tag element, for example, The tag name of the element is "div".
[0049] According to the initial tag name of the page tag to be tested, determine the tag position of the page tag to be tested in the UI page to be tested. It should be noted that the number of tags of the page tag to be tested identified or traversed may be one or more. For example, the tag traversal for the preset tag keyword "hl" is performed, and the page tag to be tested is obtained as follows:
[0050] hl-username-text id="worker1"
[0051] hl-username-text id="worker2"
[0052] hl-username-text id="project1"
[0053] hl-username-text id="project2"
[0054] The "hl-username-text" part is the initial tag name of the page tag to be tested. If the page tag to be tested has only one tag, the tag position of the page tag to be tested can be accurately located according to the initial tag name of the page tag to be tested.
[0055] In an optional embodiment, the tag position of the page tag to be tested in the UI page to be tested is determined according to the initial tag name of the page tag to be tested, including: if the page tag to be tested has only one tag, the initial tag name is determined as the target tag name of the page tag to be tested, and the tag position of the page tag to be tested in the UI page to be tested is determined according to the target tag name; or, if the page tag to be tested has at least two tags, the tail tag name corresponding to each page tag to be tested is determined according to the tag identifier of the page tag to be tested; the target tag name corresponding to each page tag to be tested is determined according to the initial tag name and the tail tag name of each page tag to be tested; and the tag position of each page tag to be tested in the UI page to be tested is determined according to the target tag name.
[0056] If the number of tags of the page to be tested is only one, the initial tag name is the target tag name of the page to be tested. Then, the tag position of the page to be tested in the UI page to be tested can be accurately located according to the target tag name.
[0057] If the number of tags to be tested is at least two, the initial tag name cannot accurately locate the position of the tag to be tested. In this case, the tag ID (identifier) is used to represent the uniqueness of the tag by introducing "id" into the tag name during the tag generation process. For example, the tags of the page to be tested are as follows:
[0058] hl-username-text id="worker1"
[0059] hl-username-text id="worker2"
[0060] hl-username-text id="project1"
[0061] hl-username-text id="project2"
[0062] The above tail tag names are id = "worker1", id = "worker2", id = "project1" and id = "project2". When the tag of the page to be tested cannot be accurately located by the initial tag name, the tail tag name can be used to accurately locate the tag of the page to be tested and determine the tag position of the tag of the page to be tested in the UI page to be tested. Specifically, "id" can be identified through the String id = element.getAttribute("id") method, and the id can be judged through the if method to obtain the tag of the page to be tested that actually needs to be operated.
[0063] The above technical solution takes into account the number of tags of the page to be tested and adopts different positioning methods to achieve accurate positioning of the page to be tested label in the UI page to be tested. There is no need for relevant technical personnel to know the names of all tags. Due to the naming diversity of personalized tag naming and traditional tag naming, the workload of knowing the naming of all tags is huge. Therefore, the initial tag name can be determined first. When the tag cannot be accurately positioned by the initial tag name, the tail tag name of each identified page to be tested label can be combined to achieve accurate positioning of the page to be tested label.
[0064] Optionally, if the page tag to be tested is a traditional page tag, the page tag to be tested is located according to the tag identifier of the page tag to be tested and the tag level correspondence between the page tag to be tested and its corresponding upper page tag and lower page tag to determine the tag position of the page tag to be tested in the UI page to be tested.
[0065] According to the code implementation logic of the functional test requirements, determine the parent page label and the child page label of the page to be tested; according to the level correspondence between the page label to be tested and the parent page label, and the level correspondence between the page label to be tested and the child page label, based on the label identifier of the page label to be tested, locate the label of the page to be tested and determine the label position of the page label to be tested in the UI page to be tested.
[0066] Optionally, the label positioning mode of the page label to be tested can also be Normal Flow, Relative Positioning, Absolute Positioning, Fixed Positioning, Sticky Positioning, Floating Positioning, Grid Layout Positioning and Flexbox Positioning.
[0067] According to the initial tag name of the page tag to be tested, determine the function method category corresponding to the page tag to be tested. For example, the function method category corresponding to the page tag to be tested can be obtained through if-else and getText().contains() methods, including but not limited to select() method, button() method, input() method and help() method.
[0068] Based on the tag position of the page to be tested, locate the code line where the page to be tested tag is located. According to the functional test type corresponding to the functional method category, perform page functional testing on the UI page to be tested and obtain the functional test results. For example, if the functional method category is the input() method, the corresponding functional test type is the data adding test type; if the functional method category is the get() method, the corresponding functional test type is the data viewing test type. Generate test data of different functional test types, and generate corresponding test code based on the test data, and perform automated testing on the page functions corresponding to the UI page to be tested.
[0069] The technical solution of the embodiment of the present invention obtains the page tag to be processed by performing tag identification on the page tag in the UI page to be tested; performs keyword identification on the page tag to be processed according to the preset tag keyword to obtain the initial tag name of the page tag to be tested; if the page tag to be tested is a personalized page tag, the tag position of the page tag to be tested in the UI page to be tested is determined according to the initial tag name of the page tag to be tested; the function method category corresponding to the page tag to be tested is determined according to the initial tag name of the page tag to be tested; according to the function test type corresponding to the function method category, based on the tag position of the page tag to be tested, the UI page to be tested is tested for page function testing, and the function test result is obtained. The above technical solution sets a personalized page tag, accurately locates based on the characteristics of the personalized page tag, and parses the personalized page tag to obtain the corresponding function method category, and performs automatic testing of the page function according to the test category corresponding to the function method category, thereby improving the UI page test efficiency, and eliminating the need for testers to manually change the tag name when the page layout is updated, which causes a waste of human resources. At the same time, the corresponding function method category of automatic positioning can realize the determination of the function method category and its corresponding function test type without manual positioning, further realizing the automation of function testing and improving the efficiency of function testing.
[0070] Embodiment 2
[0071] Figure 2 This is a flow chart of a UI page testing method provided in Embodiment 2 of the present invention. This embodiment is optimized and improved on the basis of the above technical solutions.
[0072] Further, the step of "determining the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested" is refined into "if the page tag to be tested has only one tag, then determining the initial tag name as the target tag name of the page tag to be tested, and determining the tag position of the page tag to be tested in the UI page to be tested according to the target tag name; or, if the page tag to be tested has at least two tags, then determining the tail tag name corresponding to each page tag to be tested according to the tag identifier of the page tag to be tested; determining the target tag name corresponding to each page tag to be tested according to the initial tag name and tail tag name of each page tag to be tested; and determining the tag position of each page tag to be tested in the UI page to be tested according to the target tag name." to improve the method for determining the tag position of the page tag to be tested.
[0073] The step "According to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, the page function test is performed on the UI page to be tested, and the function test result is obtained" is refined into "If the function test type corresponding to the function method category is the added data test type, a function test statement is generated according to the function method category; according to the tag position of the page tag to be tested, a function test statement is used to perform a page function test on the UI page to be tested, and the function test result is obtained.". In addition, the step "According to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, the page function test is performed on the UI page to be tested, and the function test result is obtained" is refined into "If the function test type corresponding to the function method category is the view data test type, the target tag name of the page tag to be tested is name resolved to obtain the business field, interface name and field value to be verified; based on the tag position of the page tag to be tested and according to the interface name, an interface test statement is generated, and the interface test statement is executed to obtain the interface return data; based on the business field and the interface return data, the interface return field value is determined; based on the field value to be verified and the interface feedback field value, the page function test is performed on the UI page to be tested, and the function test result is obtained." to improve the method of determining the function test result.
[0074] It should be noted that for the parts not described in detail in the embodiments of the present invention, reference can be made to the descriptions of other embodiments. Figure 2 As shown, the method comprises the following specific steps:
[0075] S210 , performing tag recognition on page tags in the UI page to be tested to obtain page tags to be processed.
[0076] S220, performing keyword recognition on the page tag to be processed according to preset tag keywords to obtain the initial tag name of the page tag to be tested; if the page tag to be tested is a personalized page tag, executing S230A-S230D; if the page tag to be tested is a traditional page tag, executing S240.
[0077] S230A: If the number of the page tag to be tested is only one, determine the initial tag name as the target tag name of the page tag to be tested, and determine the tag position of the page tag to be tested in the UI page to be tested according to the target tag name.
[0078] S230B: If the number of the page tags to be tested is at least two, determine the tail tag names corresponding to the page tags to be tested respectively according to the tag identifiers of the page tags to be tested.
[0079] S230C: Determine the target tag names corresponding to the page tags to be tested according to the initial tag names and the tail tag names of the page tags to be tested.
[0080] S230D: Determine the tag position of each to-be-tested page tag in the to-be-tested UI page according to the target tag name.
[0081] S240, positioning the page tag to be tested according to the tag identifier of the page tag to be tested and the tag level correspondence between the page tag to be tested and its corresponding upper page tag and lower page tag, and determining the tag position of the page tag to be tested in the UI page to be tested.
[0082] S250: Determine the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested.
[0083] S260A: If the function test type corresponding to the function method category is the add data test type, a function test statement is generated according to the function method category.
[0084] Among them, adding a data test type may specifically require generating random test data, and using the generated random test data to perform functional testing on corresponding functional method categories.
[0085] For example, if a functional test is performed on a user login interface of a project, the corresponding functional method category is the input method. The user login interface includes a username input box and a password input box. The specific functional test requirements are to use the existing username and its corresponding password seat to perform random test data, and input the random test data into the corresponding username and password input boxes, and automatically generate a submission test code to submit the page information, so as to obtain feedback results.
[0086] Specifically, the user name of the random test data is "administrator", and the corresponding functional test statement is "inputField.sendKeys("administrator")", which means automatically entering "administrator" in the user name input box; the functional test statement for generating the submission operation: submitButton.click() means submitting the page input information.
[0087] S260B. According to the tag position of the page tag to be tested, a function test statement is used to perform a page function test on the UI page to be tested, and a function test result is obtained.
[0088] Execute the function test statement to perform corresponding page function test on the UI page to be tested, and obtain the function test result, wherein the function test result may include a test success or a test failure error.
[0089] S270A: If the function test type corresponding to the function method category is a data viewing test type, the target tag name of the page tag to be tested is parsed to obtain a business field, an interface name, and a field value to be verified.
[0090] It should be noted that since there may be frequent demands for page function changes during UI testing, only separate interface testing can be performed during the testing process. The page test data is manually compared with the interface return data to determine whether the functional test of viewing the data has passed. This method also requires manpower for data comparison, which is inefficient.
[0091] When performing functional method testing of the view data test type, the label naming method is based on the functional data field to be tested and the interface name that returns the response data, that is, the field value to be verified. For example, the target label name of the personalized label is as follows:
[0092] hl-text-worker-getWorker-projectWorker-workerId
[0093] "hl" can represent the abbreviation of the project to be tested; "text" indicates that the field type to be tested is text type; "worker" is the business field to be tested; "getWorker-projectWorker" is the interface name, where "projectWorker" is the subordinate interface of "getWorker"; "workerId" is the field value to be verified.
[0094] By performing name resolution on the target tag name of the page tag to be tested, the business field, interface name and field value to be verified can be obtained.
[0095] S270B, based on the tag position of the page tag to be tested and according to the interface name, an interface test statement is generated, and the interface test statement is executed to obtain interface return data.
[0096] Based on the interface name, an interface test statement can be generated. The interface test statement can be used to obtain the interface return data. The interface test statement is executed to obtain the interface return data.
[0097] S270C. Determine the interface return field value according to the business field and the interface return data.
[0098] Select the interface return field value corresponding to the field that is the same as the business field from the interface feedback data.
[0099] S270D. Perform a page function test on the UI page to be tested according to the field value to be verified and the interface feedback field value, and obtain a function test result.
[0100] The field value to be verified may be a field value that needs to be verified for correctness.
[0101] In an optional embodiment, a page function test is performed on the UI page to be tested according to the field value to be verified and the interface feedback field value, and a function test result is obtained, including: comparing the field value to be verified and the interface feedback field value for consistency to obtain a consistency comparison result; if the consistency comparison result is that the consistency comparison passes, then the page function test corresponding to the page tag to be tested of the UI page to be tested passes; if the consistency comparison result is that the consistency comparison fails, then the page function test corresponding to the page tag to be tested of the UI page to be tested fails.
[0102] If the value of the field to be verified is completely consistent with the interface feedback value, the data viewing function test passes; if the value of the field to be verified is inconsistent with the interface feedback value, the data viewing function test fails.
[0103] Optionally, you can generate a print statement to print the test results. Specifically, it can be WebElementsuccessMessage = driver.findElement(By.id("failMessage")); System.out.println("Success message: " + successMessage.getText()).
[0104] Due to the special nature of page labels in the page, testers do not need to re-position page labels due to the addition of new fields or changes in the page structure tree. At the same time, the naming specification introduces corresponding functional testing methods and test items required for corresponding functional testing, which increases the possibility of combining with other testing methods and greatly improves the efficiency of automated testing. Combining with other positioning methods can also make page positioning more flexible and diverse.
[0105] The technical solution of this embodiment takes into account different functional test types. If the functional test type corresponding to the functional method category is the data adding test type, a functional test statement is generated according to the functional method category, and the functional test statement is used according to the tag position of the page tag to be tested to perform page functional testing on the UI page to be tested. If the functional test type corresponding to the functional method category is the data viewing test type, the target tag name of the page tag to be tested is name resolved, and the page functional testing of the UI page to be tested is performed based on the obtained business fields, interface names, and field values to be verified, thereby realizing automated testing of functional methods of different functional test types, and there is no need to manually judge the consistency between the interface feedback data and the data to be tested. Instead, the consistency judgment is made based on the parsed interface name and field values to be verified, further improving the test flexibility, diversity, and test efficiency.
[0106] Embodiment 3
[0107] Figure 3 The present invention provides a UI page testing device according to the third embodiment of the present invention. The present invention provides a UI page testing device, which can be used for automated testing of front-end UI pages. The UI page testing device can be implemented in the form of hardware and / or software, such as Figure 3 As shown, the UI page testing device can be configured in an electronic device, and specifically includes: a tag identification module 301, a keyword identification module 302, a tag position determination module 303, a method category determination module 304 and a function testing module 305.
[0108] The tag identification module 301 is used to identify the page tags in the user interface UI page to be tested, and obtain the page tags to be processed;
[0109] The keyword recognition module 302 is used to perform keyword recognition on the page tag to be processed according to preset tag keywords to obtain the initial tag name of the page tag to be tested;
[0110] The tag position determination module 303 is used to determine the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested if the page tag to be tested is a personalized page tag; the tag name of the personalized page tag is generated based on a preset naming specification;
[0111] A method category determination module 304 is used to determine the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested;
[0112] The function testing module 305 is used to perform page function testing on the UI page to be tested according to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, and obtain the function test result.
[0113] The above technical solution sets personalized page tags, accurately locates based on the characteristics of personalized page tags, and parses personalized page tags to obtain corresponding function method categories, and performs automated testing of page functions according to the test categories corresponding to the function method categories, thereby improving the efficiency of UI page testing, and eliminating the need for testers to manually change tag names when updating page layouts, which wastes human resources. At the same time, the corresponding function method categories that are automatically located can determine the function method categories and their corresponding function test types without manual positioning, further realizing the automation of function testing and improving the efficiency of function testing.
[0114] Optionally, the tag position determination module 303 includes:
[0115] a first tag position determining unit, configured to determine the initial tag name as the target tag name of the tag of the page to be tested if the tag number of the page to be tested is one and only one, and determine the tag position of the page to be tested tag in the UI page to be tested according to the target tag name; or
[0116] A tail tag determining unit, configured to determine tail tag names corresponding to the respective page tags to be tested according to the tag identifiers of the page tags to be tested if the number of the page tags to be tested is at least two;
[0117] A target tag determining unit, used to determine the target tag names corresponding to the page tags to be tested respectively according to the initial tag name and the tail tag name of each page tag to be tested;
[0118] The second tag position determining unit is used to determine the tag position of each of the to-be-tested page tags in the to-be-tested UI page according to the target tag name.
[0119] Optionally, the functional testing module 305 includes:
[0120] A function test statement generating unit, configured to generate a function test statement according to the function method category if the function test type corresponding to the function method category is an added data test type;
[0121] The first function testing unit is used to perform page function testing on the UI page to be tested according to the tag position of the page tag to be tested and adopt the function testing statement to obtain a function testing result.
[0122] Optionally, the functional testing module 305 includes:
[0123] A name resolution unit, configured to perform name resolution on the target tag name of the page tag to be tested to obtain a business field, an interface name and a field value to be verified if the function test type corresponding to the function method category is a data viewing test type;
[0124] An interface test statement generating unit, configured to generate an interface test statement based on the tag position of the page tag to be tested and the interface name, and execute the interface test statement to obtain interface return data;
[0125] An interface field value determining unit, configured to determine an interface return field value according to the service field and the interface return data;
[0126] The second function testing unit is used to perform a page function test on the UI page to be tested according to the field value to be verified and the interface feedback field value, and obtain a function test result.
[0127] Optionally, the second functional testing unit includes:
[0128] A consistency comparison subunit, used to compare the to-be-verified field value with the interface feedback field value for consistency, and obtain a consistency comparison result;
[0129] A test pass judgment subunit is used for, if the consistency comparison result is consistency comparison passed, then the page function test corresponding to the page tag to be tested of the UI page to be tested passes;
[0130] The test failure judgment subunit is used to determine that the page function test corresponding to the page tag to be tested of the UI page to be tested has failed if the consistency comparison result is that the consistency comparison has failed.
[0131] Optionally, the module further includes:
[0132] A tag positioning module is used to locate the tag of the page to be tested if it is a traditional page tag, and determine the tag position of the page to be tested in the UI page to be tested according to the tag identifier of the page to be tested and the tag level correspondence between the page to be tested and its corresponding upper page tag and lower page tag.
[0133] The UI page testing device provided in the embodiment of the present invention can execute the UI page testing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0134] Embodiment 4
[0135] Figure 4 A schematic diagram of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0136] like Figure 4 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0137] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0138] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 41 executes the various methods and processes described above, such as the UI page testing method.
[0139] In some embodiments, the UI page test method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the UI page test method described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to execute the UI page test method in any other appropriate manner (e.g., by means of firmware).
[0140] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0141] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0142] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0143] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0144] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0145] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0146] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0147] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A UI page testing method, characterized in that: include: Perform tag recognition on the page tags in the user interface UI page to be tested to obtain the page tags to be processed; According to the preset tag keywords, the tag of the page to be processed is subjected to keyword recognition to obtain the initial tag name of the tag of the page to be tested; If the page tag to be tested is a personalized page tag, then according to the initial tag name of the page tag to be tested, the tag position of the page tag to be tested in the UI page to be tested is determined; the tag name of the personalized page tag is generated based on a preset naming specification; Determining the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested; According to the function test type corresponding to the function method category, based on the tag position of the page tag to be tested, the page function test is performed on the UI page to be tested, and a function test result is obtained; Wherein, determining the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested includes: If the number of tags of the page tag to be tested is one and only one, the initial tag name is determined as the target tag name of the page tag to be tested, and the tag position of the page tag to be tested in the UI page to be tested is determined according to the target tag name; or, If the number of the page tags to be tested is at least two, determining the tail tag names corresponding to the page tags to be tested respectively according to the tag identifiers of the page tags to be tested; Determine the target tag names corresponding to the page tags to be tested according to the initial tag name and the tail tag name of each page tag to be tested; According to the target tag name, a tag position of each of the to-be-tested page tags in the to-be-tested UI page is determined.
2. The method according to claim 1, characterized in that The step of performing page function test on the UI page to be tested based on the function test type corresponding to the function method category and the tag position of the page tag to be tested, and obtaining the function test result includes: If the function test type corresponding to the function method category is an added data test type, generating a function test statement according to the function method category; According to the tag position of the page tag to be tested, the function test statement is used to perform a page function test on the UI page to be tested to obtain a function test result.
3. The method according to claim 1, characterized in that The step of performing page function test on the UI page to be tested based on the function test type corresponding to the function method category and the tag position of the page tag to be tested, and obtaining the function test result includes: If the function test type corresponding to the function method category is a data viewing test type, the target tag name of the page tag to be tested is parsed to obtain the business field, interface name and field value to be verified; Based on the tag position of the page tag to be tested and according to the interface name, an interface test statement is generated, and the interface test statement is executed to obtain interface return data; Determine the interface return field value according to the business field and the interface return data; According to the field value to be verified and the field value returned by the interface, a page function test is performed on the UI page to be tested, and a function test result is obtained.
4. The method according to claim 3, characterized in that The performing a page function test on the UI page to be tested according to the field value to be verified and the interface feedback field value, and obtaining a function test result, includes: Compare the to-be-verified field value with the interface feedback field value for consistency, and obtain a consistency comparison result; If the consistency comparison result is that the consistency comparison passes, then the page function test corresponding to the page tag to be tested of the UI page to be tested passes; If the consistency comparison result is that the consistency comparison fails, the page function test corresponding to the page tag to be tested of the UI page to be tested fails.
5. The method according to claim 1, characterized in that The method further comprises: If the page tag to be tested is a traditional page tag, the page tag to be tested is tag positioned according to the tag identifier of the page tag to be tested and the tag level correspondence between the page tag to be tested and its corresponding upper page tag and lower page tag to determine the tag position of the page tag to be tested in the UI page to be tested.
6. A UI page testing device, characterized in that: include: The tag recognition module is used to identify the page tags in the user interface UI page to be tested and obtain the page tags to be processed; A keyword recognition module, used to perform keyword recognition on the page tag to be processed according to preset tag keywords, and obtain an initial tag name of the page tag to be tested; A tag position determination module, for determining the tag position of the page tag to be tested in the UI page to be tested according to the initial tag name of the page tag to be tested if the page tag to be tested is a personalized page tag; the tag name of the personalized page tag is generated based on a preset naming specification; A method category determination module, used to determine the function method category corresponding to the page tag to be tested according to the initial tag name of the page tag to be tested; A function test module, used for performing page function test on the UI page to be tested according to the function test type corresponding to the function method category and based on the tag position of the page tag to be tested, and obtaining a function test result; Wherein, the tag position determination module includes: a first tag position determining unit, configured to determine the initial tag name as the target tag name of the tag of the page to be tested if the tag number of the page to be tested is one and only one, and determine the tag position of the page to be tested tag in the UI page to be tested according to the target tag name; or A tail tag determining unit, configured to determine tail tag names corresponding to the respective page tags to be tested according to the tag identifiers of the page tags to be tested if the number of the page tags to be tested is at least two; A target tag determining unit, used to determine the target tag names corresponding to the page tags to be tested respectively according to the initial tag name and the tail tag name of each page tag to be tested; The second tag position determining unit is used to determine the tag position of each of the to-be-tested page tags in the to-be-tested UI page according to the target tag name.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the UI page testing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the UI page testing method according to any one of claims 1 to 5 when executed.
9. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the UI page testing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Page testing method and device, computer equipment and storage medium
CN112199296A
Page element testing method and device, equipment and storage medium
CN113448849A