Page encapsulation methods and apparatus, storage media and electronic devices
By generating network identifiers and searching for similar pages, the problem of repetitive encapsulation in web automation testing is solved, achieving efficient page encapsulation and improving development efficiency.
Patent Information
- Application Number
- CN202310187348.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-02-28
AI Technical Summary
Existing web automation testing suffers from a large amount of redundant code due to repetitive page definitions, resulting in heavy maintenance workload and low development efficiency.
By generating a network identifier for the current page to be encapsulated, and using the network identifier and network address to find similar reference pages, encapsulation is performed only when no similar reference page exists, thus avoiding duplicate encapsulation.
It reduces the generation of redundant code, improves development efficiency, and reduces maintenance workload.
Smart Images

Figure CN116382766B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart home technology, and more specifically, to a method and apparatus for encapsulating a page, a storage medium, and an electronic device. Background Technology
[0002] With the rapid development of the Internet, the types of software have shifted from Windows desktop programs to web pages and mobile applications dominated by browsers. Browser / Server has evolved from a simple two-tier architecture to a multi-tier architecture and microservices, and automated testing technology has also gradually entered a new era.
[0003] Current web automation testing places high demands on the R&D capabilities of test engineers, while also increasing their workload. The team-level capability requirements and infrastructure development brought about by built-in quality control cannot be implemented in a short period of time. Therefore, it is crucial to find a way to achieve web automation development at low cost and with low barriers to entry.
[0004] The most mainstream web automation development at present is based on the PO pattern, which treats the page as an object, the elements on the page as the object's properties, and a series of business operations as the object's methods.
[0005] The development of Web automation PO pattern requires testers to encapsulate the page from a subjective perspective. However, automation development is often a collaborative effort involving multiple people. Different people do not have a unified concept of the dimensions of the page to be encapsulated. Due to repeated page definitions, there may be a large amount of duplicate and redundant code, the maintenance workload will increase day by day, and the development efficiency will be significantly reduced.
[0006] Regarding the issues in related technologies, such as the potential for a large amount of redundant code due to repeated page definitions, no effective solution has yet been proposed. Summary of the Invention
[0007] This application provides a method and apparatus for encapsulating pages, a storage medium, and an electronic device to at least solve the problem in the related art that there may be a large amount of duplicate and redundant code due to repeated page definitions.
[0008] According to one embodiment of this application, a page encapsulation method is provided, comprising: generating a network identification code matching the current page to be encapsulated based on object attribute information of component objects contained in the current page to be encapsulated; using the network identification code and the network address of the current page to be encapsulated, searching for whether there is a reference page similar to the current page to be encapsulated, wherein the page similarity between the reference page and the current page to be encapsulated is greater than a target threshold, and the reference page is an encapsulated page; if there is no reference page similar to the current page to be encapsulated, encapsulating the current page to be encapsulated based on the attribute information of the component objects in the current page to be encapsulated.
[0009] In one exemplary embodiment, generating a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated includes: determining the quantity information and the type information of the component objects based on the object attribute information; determining a first string corresponding to the quantity information and a second string corresponding to the type information; and calculating the first string and the second string using a message digest algorithm to generate a network identification code matching the current page to be encapsulated.
[0010] In an exemplary embodiment, before generating a network identifier matching the current page to be packaged based on the object attribute information of the component objects contained in the current page to be packaged, the method further includes: obtaining a first script for scanning the current page to be packaged; running the first script to determine the component objects of the current page to be packaged and the quantity information of the component objects through a selector in the first script, wherein the selector is used to locate the component objects on the current page to be packaged; and determining the type information of the component objects based on the configuration information of the component objects, wherein the configuration information is used to indicate the parameter configuration of the component objects.
[0011] In one exemplary embodiment, obtaining a first script for scanning the current page to be encapsulated includes: automatically generating a second script based on pre-recorded use case operations, wherein the use case operations are used to indicate operations performed on the current page to be encapsulated; processing each line of code in the second script to determine identification information of the current page to be encapsulated in the second script; determining a corresponding scanning method based on the identification information as a parameter, wherein the scanning method is a method for indicating scanning component objects on the current page to be encapsulated; and inserting the scanning method into the second script to generate the first script.
[0012] In one exemplary embodiment, automatically generating a second script based on pre-recorded use case operations includes: determining a predefined component object of the system and attribute information of the component object; determining a selector corresponding to the current page object to be encapsulated based on the attribute information, wherein the selector is used to locate the component object in the current page to be encapsulated; and generating the second script based on the selector and the use case operations.
[0013] In an exemplary embodiment, after encapsulating the current page to be encapsulated, the method further includes: determining the page object of the current page to be encapsulated based on the component object of the current page to be encapsulated; generating a target file based on the page object of the current page to be encapsulated and the use case operation code corresponding to the current page to be encapsulated; and sending the target file to a terminal device so that the terminal device displays the target file.
[0014] In one exemplary embodiment, encapsulating the current page to be encapsulated based on the attribute information of component objects in the current page to be encapsulated includes: obtaining attribute information and configuration information of multiple component objects in the current page to be encapsulated; and encapsulating the multiple component objects based on the attribute information and configuration information to obtain the encapsulated current page to be encapsulated.
[0015] According to another embodiment of this application, a page encapsulation device is also provided, comprising: a generation module, configured to generate a network identification code matching the current page to be encapsulated based on object attribute information of component objects contained in the current page to be encapsulated; a search module, configured to use the network identification code and the network address of the current page to be encapsulated to search for whether there is a reference page similar to the current page to be encapsulated, wherein the page similarity between the reference page and the current page to be encapsulated is greater than a target threshold, and the reference page is an encapsulated page; and an encapsulation module, configured to encapsulate the current page to be encapsulated based on the attribute information of the component objects in the current page to be encapsulated when no reference page similar to the current page to be encapsulated exists.
[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the encapsulation method of the above-described page at runtime.
[0017] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the page encapsulation method described above through the computer program.
[0018] In this embodiment, a network identifier matching the current page to be encapsulated is generated based on the object attribute information of the component objects contained in the current page to be encapsulated. Using the network identifier and the network address of the current page to be encapsulated, a search is conducted to determine if a reference page similar to the current page to be encapsulated exists. The reference page is considered an encapsulated page if its page similarity to the current page to be encapsulated is greater than a target threshold. If no reference page similar to the current page to be encapsulated exists, the current page to be encapsulated is encapsulated based on the attribute information of the component objects in the current page to be encapsulated. This technical solution solves the problem of potentially large amounts of redundant code due to repeated page definitions. This embodiment distinguishes different pages by using the network address and network identifier of the current page to be encapsulated. Therefore, for pages with the same network address and network identifier, only one page is encapsulated, thus achieving the technical effect of not repeatedly encapsulating the same page. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram of the hardware environment for a page encapsulation method according to an embodiment of this application;
[0022] Figure 2 This is a flowchart of a page encapsulation method according to an embodiment of this application;
[0023] Figure 3 This is a schematic diagram of a page encapsulation method according to an embodiment of this application;
[0024] Figure 4 This is a structural block diagram (a) of a page encapsulation device according to an embodiment of this application;
[0025] Figure 5 This is a structural block diagram (II) of a page encapsulation device according to an embodiment of this application. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] According to one aspect of the embodiments of this application, a page encapsulation method is provided. This page encapsulation method is widely used in whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligencehouse ecosystems. Optionally, in this embodiment, the above-mentioned page encapsulation method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0029] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0030] This embodiment provides a page encapsulation method applied to a computer terminal. Figure 2 This is a flowchart of a page encapsulation method according to an embodiment of this application, the process including the following steps:
[0031] Step S202: Generate a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated.
[0032] It should be noted that the object attribute information includes: the quantity information of the component objects and the type information of the component objects.
[0033] Step S204: Using the network identification code and the network address of the current page to be packaged, search for whether there is a reference page similar to the current page to be packaged. The reference page is a packaged page if the page similarity between the reference page and the current page to be packaged is greater than a target threshold.
[0034] It should be noted that in this embodiment of the invention, two conditions are used to identify the page: 1) the page's network address; 2) the page's network identification code (idCode).
[0035] Step S206: If there is no reference page similar to the current page to be encapsulated, the current page to be encapsulated is encapsulated according to the attribute information of the component objects in the current page to be encapsulated.
[0036] It should be noted that if there is a reference page similar to the current page to be packaged, it means that the current page to be packaged has already been packaged. In order to reduce the generation of redundant code, the current page to be packaged will not be packaged again.
[0037] Through the above steps, a network identifier matching the current page to be encapsulated is generated based on the object attribute information of the component objects contained in the current page to be encapsulated. Using the network identifier and the network address of the current page to be encapsulated, a search is conducted to determine if a reference page similar to the current page to be encapsulated exists. If the page similarity between the reference page and the current page to be encapsulated is greater than a target threshold, the reference page is considered an encapsulated page. If no reference page similar to the current page to be encapsulated exists, the current page to be encapsulated is encapsulated based on the attribute information of the component objects in the current page to be encapsulated. This solves the problem in related technologies where repeated page definitions may lead to a large amount of redundant code. This embodiment of the invention distinguishes different pages by using the network address and network identifier of the current page to be encapsulated. Furthermore, for pages with the same network address and network identifier, only one page is encapsulated, thus achieving the technical effect of not repeatedly encapsulating the same page.
[0038] In one exemplary embodiment, generating a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated includes: determining the quantity information and the type information of the component objects based on the object attribute information; determining a first string corresponding to the quantity information and a second string corresponding to the type information; and calculating the first string and the second string using a message digest algorithm to generate a network identification code matching the current page to be encapsulated.
[0039] It should be noted that, in this embodiment of the invention, the network identification code matching the current page to be packaged is generated by using the quantity information of the component objects and the type information of the component objects. Specifically: a first string corresponding to the quantity information and a second string corresponding to the type information are determined; a third string composed of the first string and the second string is calculated to obtain the network identification code matching the current page to be packaged.
[0040] It should be noted that the message digest algorithm in this invention can be MD2, MD4, MD5, etc., and the embodiments of this invention do not limit it.
[0041] Since current front-end pages often favor a single-page design style, it's possible for pages to have the same URL but vastly different page components. According to the method in this embodiment of the invention, a network identifier matching the current page to be encapsulated can be generated. This allows for the differentiation of different pages using the network address and the network identifier of the current page to be encapsulated. Even if pages have the same network address, they can still be distinguished by the matching network identifier. This embodiment of the invention distinguishes different pages using the network address and network identifier of the current page to be encapsulated. Therefore, for pages with the same network address and network identifier, only one page is encapsulated, thus achieving the technical effect of avoiding duplicate encapsulation of identical pages.
[0042] In an exemplary embodiment, before generating a network identifier matching the current page to be packaged based on the object attribute information of the component objects contained in the current page to be packaged, the method includes: obtaining a first script for scanning the current page to be packaged; running the first script to determine the component objects of the current page to be packaged and the quantity information of the component objects through a selector in the first script, wherein the selector is used to locate the component objects on the current page to be packaged; and determining the type information of the component objects based on the configuration information of the component objects, wherein the configuration information is used to indicate the parameter configuration of the component objects.
[0043] It should be noted that when the first script is run to scan the current page to be encapsulated, it will traverse all predefined component objects in the system and determine the component object of the current page to be encapsulated through the selector in the first script. Then, when the component object is determined, the type information of the component object is determined according to the configuration information of the component object.
[0044] In one exemplary embodiment, obtaining a first script for scanning the current page to be encapsulated includes: automatically generating a second script based on pre-recorded use case operations, wherein the use case operations are used to indicate operations performed on the current page to be encapsulated; processing each line of code in the second script to determine identification information of the current page to be encapsulated in the second script; determining a corresponding scanning method based on the identification information as a parameter, wherein the scanning method is a method for indicating scanning component objects on the current page to be encapsulated; and inserting the scanning method into the second script to generate the first script.
[0045] In this embodiment of the invention, a series of test case operations are recorded using Playwright, and a second script is automatically generated based on the recorded test case operations. Each line of code in the second script is processed, and the tag information of the current page to be encapsulated in the second script is used as a parameter to insert a scanning method. It should be noted that when using Playwright as an automation framework, the codeGen function of the framework can record page operations and generate a second script.
[0046] In one exemplary embodiment, automatically generating a second script based on pre-recorded use case operations includes: determining a predefined component object of the system and attribute information of the component object; determining a selector corresponding to the current page object to be encapsulated based on the attribute information, wherein the selector is used to locate the component object in the current page to be encapsulated; and generating the second script based on the selector and the use case operations.
[0047] It should be noted that, in this embodiment of the invention, the frequently used component objects on the front end need to be defined according to the system, such as the button component, and the scan_selector property needs to be configured for the component object. The scan_selector property is the selector used when scanning the page, and the component object is located on the current page to be encapsulated by the selector.
[0048] In one exemplary embodiment, after encapsulating the current page to be encapsulated, the method further includes: determining the page object of the current page to be encapsulated based on the component object of the current page to be encapsulated; generating a target file based on the page object of the current page to be encapsulated and the use case operation code corresponding to the current page to be encapsulated; and sending the target file to a terminal device so that the terminal device displays the target file.
[0049] In other words, when the script finishes running, it automatically exports a JSON file. The JSON file includes the page object of the current page to be packaged, which was scanned by the first script, and the test case operation code corresponding to the current page to be packaged. Developers can then check and maintain the page object of the current page to be packaged and the test case operation code corresponding to the current page to be packaged based on the JSON file.
[0050] In one exemplary embodiment, encapsulating the current page to be encapsulated based on the attribute information of component objects in the current page to be encapsulated includes: obtaining attribute information and configuration information of multiple component objects in the current page to be encapsulated; and encapsulating the multiple component objects based on the attribute information and configuration information to obtain the encapsulated current page to be encapsulated.
[0051] It should be noted that the methods for encapsulating the component object include: overall encapsulation and custom encapsulation, and the embodiments of the present invention do not limit the methods.
[0052] To better understand the process of the above page encapsulation method, the implementation flow of the above page encapsulation method will be described below in conjunction with optional embodiments, but this is not intended to limit the technical solution of the embodiments of this application.
[0053] This embodiment provides a method for encapsulating a page. Figure 3 This is a schematic diagram of a page encapsulation method according to an embodiment of this application, such as... Figure 3 As shown, the specific steps are as follows:
[0054] Step S301: Define frequently used component objects for the front-end pages according to the project;
[0055] For example, in the button component, the scan_selector property of the component object is defined. The scan_selector property is the selector used when scanning the page. The selector is used to locate the component object on the front-end page.
[0056] Step S302: Record a series of use case operations using Playwright, and generate a second script based on the use case operations;
[0057] Step S303: Based on the second script, process each line of code in the second script, take the page object in the second script as a parameter, insert a scan method corresponding to the page object, and obtain the first script;
[0058] Step S304: Run the first script to scan the front-end page;
[0059] When scanning the front-end page, it iterates through all the component objects defined in the front-end page and scans out the component objects on the page according to the scan_selector attribute of the component objects. Finally, it generates a page object based on the component objects on the page. After removing invalid data from the page object, it uses the MD5 algorithm to generate the idCode value corresponding to the front-end page according to the number and type of component objects.
[0060] Step S305: After the script finishes running, a JSON file is automatically exported. The JSON file includes: a list of page objects corresponding to the front-end pages involved in the second script and the test case operation code corresponding to the front-end pages.
[0061] Step S306: Determine all page information involved in the execution of the first script through the JSON file. Subsequent page encapsulation can then distinguish different pages based on the idCode and page path, thereby completing the page encapsulation under the standardized PO pattern.
[0062] In this embodiment of the invention, Playwright is used as the automation framework. Playwright's CodeGen function can record page operations and generate code, making its location of page elements more reliable than other automation frameworks. Through the recording function and the designed scanning scheme, the development threshold is lowered. After developing the script, users obtain the page's idCode value and then distinguish different pages based on the page's idCode value and network address, leading to more standardized encapsulation of subsequent pages.
[0063] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0064] Figure 4 This is a structural block diagram (a) of a page encapsulation device according to an embodiment of this application; as shown Figure 4 As shown, it includes:
[0065] The generation module 42 is used to generate a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated.
[0066] The search module 44 is used to search for whether there is a reference page similar to the current page to be packaged using the network identification code and the network address of the current page to be packaged. The reference page is a packaged page if the page similarity between the reference page and the current page to be packaged is greater than a target threshold.
[0067] The encapsulation module 46 is used to encapsulate the current page to be encapsulated based on the attribute information of the component objects in the current page to be encapsulated when there is no reference page similar to the current page to be encapsulated.
[0068] Using the aforementioned apparatus, a network identifier matching the current page to be packaged is generated based on the object attribute information of the component objects contained in the current page to be packaged. The network identifier and the network address of the current page to be packaged are used to search for a reference page similar to the current page to be packaged. If the page similarity between the reference page and the current page to be packaged is greater than a target threshold, the reference page is considered a packaged page. If no reference page similar to the current page to be packaged exists, the current page to be packaged is packaged based on the attribute information of the component objects in the current page to be packaged. This solves the problem in related technologies where repeated page definitions may lead to a large amount of redundant code. This embodiment of the invention distinguishes different pages by using the network address and network identifier of the current page to be packaged. Therefore, for pages with the same network address and network identifier, only one page is packaged, thus achieving the technical effect of not repeatedly packaging the same page.
[0069] In an exemplary embodiment, the generation module 42 is configured to determine the quantity information and type information of the component objects based on the object attribute information; determine a first string corresponding to the quantity information and a second string corresponding to the type information; and calculate the first string and the second string using a message digest algorithm to generate a network identification code matching the current page to be encapsulated.
[0070] It should be noted that, in this embodiment of the invention, the network identification code matching the current page to be packaged is generated by using the quantity information of the component objects and the type information of the component objects. Specifically: a first string corresponding to the quantity information and a second string corresponding to the type information are determined; a third string composed of the first string and the second string is calculated to obtain the network identification code matching the current page to be packaged.
[0071] It should be noted that the message digest algorithm in this invention can be MD2, MD4, MD5, etc., and the embodiments of this invention do not limit it.
[0072] Since current front-end pages often favor a single-page design style, it's possible for pages to have the same URL but vastly different page components. According to the method in this embodiment of the invention, a network identifier matching the current page to be encapsulated can be generated. This allows for the differentiation of different pages using the network address and the network identifier of the current page to be encapsulated. Even if pages have the same network address, they can still be distinguished by the matching network identifier. This embodiment of the invention distinguishes different pages using the network address and network identifier of the current page to be encapsulated. Therefore, for pages with the same network address and network identifier, only one page is encapsulated, thus achieving the technical effect of avoiding duplicate encapsulation of identical pages.
[0073] In one exemplary embodiment, Figure 5 This is a structural block diagram (II) of a page encapsulation device according to an embodiment of this application; as shown Figure 5 As shown, the above-mentioned device further includes: an acquisition module 52, configured to acquire a first script for scanning the current page to be packaged; a running module 54, configured to run the first script to determine the component objects of the current page to be packaged and the quantity information of the component objects through a selector in the first script, wherein the selector is used to locate the component objects on the current page to be packaged; and a determination module 56, configured to determine the type information of the component objects according to the configuration information of the component objects, wherein the configuration information is used to indicate the parameter configuration of the component objects.
[0074] It should be noted that when the first script is run to scan the current page to be encapsulated, it will traverse all predefined component objects in the system and determine the component object of the current page to be encapsulated through the selector in the first script. Then, when the component object is determined, the type information of the component object is determined according to the configuration information of the component object.
[0075] In one exemplary embodiment, the acquisition module 52 is configured to automatically generate a second script based on pre-recorded use case operations, wherein the use case operations are used to indicate operations to be performed on the current page to be encapsulated; process each line of code in the second script to determine the identification information of the current page to be encapsulated in the second script; determine a corresponding scanning method based on the identification information as a parameter, wherein the scanning method is a method for indicating scanning of component objects on the current page to be encapsulated; and insert the scanning method into the second script to generate the first script.
[0076] In an exemplary embodiment, the acquisition module 52 is configured to determine the predefined component objects of the system and the attribute information of the component objects; determine the selector corresponding to the current page object to be encapsulated based on the attribute information, wherein the selector is used to locate the component objects in the current page to be encapsulated; and generate the second script based on the selector and the use case operation.
[0077] In an exemplary embodiment, the determining module 56 is configured to determine the page object of the current page to be encapsulated based on the component object of the current page to be encapsulated; generate a target file based on the page object of the current page to be encapsulated and the use case operation code corresponding to the current page to be encapsulated; and send the target file to a terminal device so that the terminal device displays the target file.
[0078] In one exemplary embodiment, the encapsulation module 54 is used to obtain attribute information and configuration information of multiple component objects in the current page to be encapsulated; and to encapsulate the multiple component objects according to the attribute information and configuration information to obtain the encapsulated current page to be encapsulated.
[0079] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.
[0080] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0081] S1, Generate a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated;
[0082] S2, using the network identification code and the network address of the current page to be packaged, search for whether there is a reference page similar to the current page to be packaged, wherein the page similarity between the reference page and the current page to be packaged is greater than a target threshold, and the reference page is a packaged page;
[0083] S3, if there is no reference page similar to the current page to be encapsulated, encapsulate the current page to be encapsulated according to the attribute information of the component objects in the current page to be encapsulated.
[0084] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0085] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0086] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0087] S1, Generate a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated;
[0088] S2, using the network identification code and the network address of the current page to be packaged, search for whether there is a reference page similar to the current page to be packaged, wherein the page similarity between the reference page and the current page to be packaged is greater than a target threshold, and the reference page is a packaged page;
[0089] S3, if there is no reference page similar to the current page to be encapsulated, encapsulate the current page to be encapsulated according to the attribute information of the component objects in the current page to be encapsulated.
[0090] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0091] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0092] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0093] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method of encapsulating a page, characterized by, include: Based on the object attribute information of the component objects contained in the current page to be encapsulated, generate a network identification code that matches the current page to be encapsulated; Using the network identification code and the network address of the current page to be packaged, search for whether there is a reference page similar to the current page to be packaged. The reference page is considered to be a packaged page if the page similarity between the reference page and the current page to be packaged is greater than a target threshold. If there is no reference page similar to the current page to be encapsulated, the current page to be encapsulated is encapsulated according to the attribute information of the component objects in the current page to be encapsulated. The process of generating a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated includes: determining the quantity information and type information of the component objects based on the object attribute information; determining a first string corresponding to the quantity information and a second string corresponding to the type information; and calculating the first string and the second string using a message digest algorithm to generate a network identification code matching the current page to be encapsulated. Before generating the network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated, the method further includes: A second script is automatically generated based on pre-recorded use case operations, wherein the use case operations are used to indicate operations to be performed on the current page to be encapsulated; each line of code in the second script is processed to determine the identification information of the current page to be encapsulated in the second script; a corresponding scanning method is determined based on the identification information as a parameter, wherein the scanning method is a method used to indicate scanning of component objects on the current page to be encapsulated; the scanning method is inserted into the second script to generate a first script; the first script is run to determine the component objects of the current page to be encapsulated and the number of component objects through a selector in the first script, wherein the selector is used to locate the component objects on the current page to be encapsulated; the type information of the component objects is determined based on the configuration information of the component objects, wherein the configuration information is used to indicate parameter configuration for the component objects.
2. The method of claim 1, wherein, A second script is automatically generated based on pre-recorded test case operations, including: Determine the predefined component objects in the system, as well as the attribute information of the component objects; The selector corresponding to the current page object to be encapsulated is determined based on the attribute information, wherein the selector is used to locate the component object in the current page to be encapsulated; The second script is generated based on the selector and the use case operation.
3. The page encapsulation method according to any one of claims 1-2, characterized in that, After encapsulating the current page to be encapsulated, the method further includes: The page object of the current page to be encapsulated is determined based on the component object of the current page to be encapsulated; Generate a target file based on the page object of the current page to be encapsulated and the use case operation code corresponding to the current page to be encapsulated; The target file is sent to the terminal device so that the terminal device displays the target file.
4. The page encapsulation method according to any one of claims 1-2, characterized in that, Based on the attribute information of the component objects in the current page to be encapsulated, the current page to be encapsulated is encapsulated, including: Obtain the attribute information and configuration information of multiple component objects in the current page to be encapsulated; The multiple component objects are encapsulated based on the attribute information and configuration information to obtain the current page to be encapsulated.
5. A page encapsulation device, characterized in that, include: The generation module is used to generate a network identification code matching the current page to be encapsulated based on the object attribute information of the component objects contained in the current page to be encapsulated. The search module is used to search for whether there is a reference page similar to the current page to be packaged using the network identification code and the network address of the current page to be packaged. The reference page is an already packaged page if the page similarity between the reference page and the current page to be packaged is greater than a target threshold. The encapsulation module is used to encapsulate the current page to be encapsulated based on the attribute information of the component objects in the current page to be encapsulated when there is no reference page similar to the current page to be encapsulated. The generation module is further configured to determine the quantity information and type information of the component objects based on the object attribute information; determine a first string corresponding to the quantity information and a second string corresponding to the type information; and calculate the first string and the second string using a message digest algorithm to generate a network identification code matching the current page to be encapsulated. The generation module is further configured to: automatically generate a second script based on pre-recorded use case operations, wherein the use case operations are used to indicate operations to be performed on the current page to be encapsulated; process each line of code in the second script to determine the identification information of the current page to be encapsulated in the second script; determine a corresponding scanning method based on the identification information as a parameter, wherein the scanning method is a method used to indicate scanning of component objects on the current page to be encapsulated; insert the scanning method into the second script to generate a first script; run the first script to determine the component objects of the current page to be encapsulated and the number of component objects through a selector in the first script, wherein the selector is used to locate the component objects on the current page to be encapsulated; and determine the type information of the component objects based on the configuration information of the component objects, wherein the configuration information is used to indicate parameter configuration for the component objects.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 4.
7. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 4 through the computer program.
Citation Information
Patent Citations
Smart television video sharing method and video sharing system
CN106131613A
