CN110764994A - Page element packaging method and device, electronic equipment and storage medium - Google Patents

Page element packaging method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN110764994A
CN110764994A CN201910833456.9A CN201910833456A CN110764994A CN 110764994 A CN110764994 A CN 110764994A CN 201910833456 A CN201910833456 A CN 201910833456A CN 110764994 A CN110764994 A CN 110764994A
Authority
CN
China
Prior art keywords
page
elements
test
packaging
unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910833456.9A
Other languages
Chinese (zh)
Inventor
郭奕明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Priority to CN201910833456.9A priority Critical patent/CN110764994A/en
Publication of CN110764994A publication Critical patent/CN110764994A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a page element packaging method and device, electronic equipment and a storage medium. The page element packaging method can automatically acquire a test page when a packaging instruction is received, comprehensively captures all elements of the test page by adopting a web crawler technology, further determines demand data from the packaging instruction, determines a classification label according to the demand data, further splits all the elements according to the classification label, and packages the split elements as objects, thereby realizing effective classification of page elements, testing by using the classified elements and improving the execution efficiency.

Description

Page element packaging method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of test technologies, and in particular, to a page element packaging method and apparatus, an electronic device, and a storage medium.
Background
In the prior art, when a tester tests, in order to simplify a test flow, a large number of elements on a test page are often packaged to facilitate subsequent direct use, but the above process steps are complicated.
Moreover, although some test tools in the world can realize the function of global capture of page elements, the test tools are not generally suitable for all test tools, and parameters of packaged objects are disordered and inconvenient to read.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a page element packaging method, device, electronic device and storage medium, which can effectively classify page elements, and can perform testing by using the classified elements, thereby improving the execution efficiency.
A page element encapsulation method, the method comprising:
when a packaging instruction is received, a test page is obtained;
capturing all elements of the test page by adopting a web crawler technology;
determining demand data from the packaging instructions;
determining a classification label according to the demand data;
splitting all the elements according to the classification labels;
and packaging the split elements into objects.
According to the preferred embodiment of the present invention, when the package instruction is received, the acquiring the test page includes:
acquiring a page address from the packaging instruction;
and positioning the test page according to the page address.
According to the preferred embodiment of the present invention, said crawling all elements of the test page by using web crawler technology comprises:
adopting a web crawler technology to capture a directory tree of the test page;
determining all subdirectories in the directory tree;
and taking the elements of each subdirectory in all subdirectories as all elements of the test page.
According to a preferred embodiment of the present invention, said splitting all elements according to the classification label comprises:
determining a regular expression corresponding to the classification label;
splitting all the elements by the regular expression.
According to a preferred embodiment of the present invention, said encapsulating the split element as an object includes:
exporting the split elements into texts;
naming the text;
and saving the named text as the object.
According to a preferred embodiment of the present invention, said naming said text comprises:
acquiring a classification label of the text;
naming the text with the classification label;
when repeated naming occurs, prompt information is sent out.
According to a preferred embodiment of the present invention, after packaging the split element as an object, the method further comprises:
when a test task is received, determining a test environment of the test task;
converting the object into code corresponding to the test environment;
executing the test task with the code.
A page element encapsulation apparatus, the apparatus comprising:
the acquisition unit is used for acquiring a test page when a packaging instruction is received;
the grabbing unit is used for grabbing all elements of the test page by adopting a web crawler technology;
the determining unit is used for determining the demand data from the packaging instruction;
the determining unit is further configured to determine a classification label according to the demand data;
the splitting unit is used for splitting all the elements according to the classification labels;
and the packaging unit is used for packaging the split elements into objects.
According to a preferred embodiment of the present invention, the obtaining unit is specifically configured to:
acquiring a page address from the packaging instruction;
and positioning the test page according to the page address.
According to a preferred embodiment of the present invention, the grasping unit is specifically configured to:
adopting a web crawler technology to capture a directory tree of the test page;
determining all subdirectories in the directory tree;
and taking the elements of each subdirectory in all subdirectories as all elements of the test page.
According to a preferred embodiment of the present invention, the splitting unit is specifically configured to:
determining a regular expression corresponding to the classification label;
splitting all the elements by the regular expression.
According to a preferred embodiment of the present invention, the encapsulating unit encapsulates the split element as an object, including:
exporting the split elements into texts;
naming the text;
and saving the named text as the object.
According to a preferred embodiment of the present invention, the naming the text by the encapsulation unit includes:
acquiring a classification label of the text;
naming the text with the classification label;
when repeated naming occurs, prompt information is sent out.
According to a preferred embodiment of the present invention, the determining unit is further configured to determine, when a test task is received after packaging the split element as an object, a test environment of the test task;
the device further comprises:
a conversion unit for converting the object into a code corresponding to the test environment;
an execution unit to execute the test task with the code.
An electronic device, the electronic device comprising:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the page element encapsulation method.
A computer-readable storage medium having stored therein at least one instruction for execution by a processor in an electronic device to implement the page element encapsulation method.
According to the technical scheme, the test page can be automatically acquired when the packaging instruction is received, all elements of the test page are comprehensively captured by adopting a web crawler technology, the demand data are further determined from the packaging instruction, the classification tags are determined according to the demand data, all the elements are further split according to the classification tags, and the split elements are packaged as objects, so that the page elements are effectively classified, the classified elements can be used for testing, and the execution efficiency is improved.
Drawings
FIG. 1 is a flow chart of a page element encapsulation method according to a preferred embodiment of the present invention.
FIG. 2 is a functional block diagram of a page element packaging apparatus according to a preferred embodiment of the present invention.
FIG. 3 is a schematic structural diagram of an electronic device implementing a page element encapsulation method according to a preferred embodiment of the invention.
Description of the main elements
Figure BDA0002191473060000041
Figure BDA0002191473060000051
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flow chart of a page element encapsulation method according to a preferred embodiment of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The page element packaging method is applied to one or more electronic devices, where the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), an intelligent wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a cloud computing (cloud computing) based cloud consisting of a large number of hosts or network servers.
The Network where the electronic device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
S10, when the package instruction is received, the test page is obtained.
In at least one embodiment of the present invention, an HTML (HyperText Markup Language) is a programming Language necessary for making a Web page, and the Web page is mostly designed in the market by using the HTML, and the essence of the Web page is the HyperText Markup Language, and by combining with other Web (internet) technologies (such as scripting Language, public gateway interface, components, and the like), a powerful Web page can be created.
Therefore, the test page in this embodiment is a web page designed in HTML language, so that the present disclosure has higher practicability.
In at least one embodiment of the present invention, the test page may include a main page, a navigation page, a merchandise page, and the like.
In at least one embodiment of the present invention, the obtaining, by the electronic device, the test page when the package instruction is received includes:
and the electronic equipment acquires a page address from the packaging instruction, and further, the electronic equipment positions the test page according to the page address.
In at least one embodiment of the present invention, the package instructions may include, but are not limited to, one or more of the following: page address, demand data, etc.
In this embodiment, the electronic device links to a webpage corresponding to the page address, and uses the linked webpage as the test page.
By the implementation method, the test page can be accurately acquired, so that elements can be captured from the test page subsequently.
And S11, adopting a web crawler technology to capture all elements of the test page.
In at least one embodiment of the invention, the all elements refer to html element sets for constructing page frames.
Specifically, all of the elements may include, but are not limited to, combinations of one or more of the following:
html script, body, head, font, table, tr, td, a link, picture link, text content, etc.
In at least one embodiment of the present invention, the electronic device crawling all elements of the test page by using a web crawler technology includes:
the electronic equipment captures a directory tree of the test page by adopting a web crawler technology, further determines all subdirectories in the directory tree, and takes elements of each subdirectory in all subdirectories as all elements of the test page.
The web crawler (web crawler) is also called a web spider, and is a technology for automatically crawling a directory tree of any page according to a certain rule.
Specifically, in this embodiment, the fetching policy of the directory tree of the test page may include, but is not limited to: Depth-First-Search (DFS), Breadth-First Search (BFS), and Best-First Search (Best-First Search), among others.
In many cases, the depth-first search method may cause a problem of trapping of a crawler, and therefore, in this embodiment, the electronic device employs the breadth-first search method and the best-first search method.
In at least one embodiment of the invention, the directory tree is composed of a series of program segments, each web page has its own directory tree, and the directory trees of different web pages are different.
For example: each search engine (such as Baidu search, Google search, instant search, etc.) has its own directory tree, and the directory trees of the search engines are different.
Further, the electronic device captures all elements of the test page by using a web crawler technology.
For example: the electronic equipment traverses the test page by adopting the breadth-first search method, and the electronic equipment sets the link depth to be between 2 and 5. In the process of traversing the web page, the electronic device captures a URL (Uniform Resource Locator) in the page, uses keywords and/or tags in the URL as elements of each subdirectory, and further determines all elements of the test page.
The breadth-first search strategy is a graph search calculation strategy. Briefly, the breadth-first search strategy is to traverse the nodes of the tree along its width, starting at the root node, and if a target is found, the search terminates.
Through the implementation mode, all elements in the test page can be captured, and the situation that the elements are not captured is avoided.
And S12, determining the demand data from the packaging instruction.
In at least one embodiment of the invention, the electronic device may retrieve the demand data directly from the package instructions.
In at least one embodiment of the invention, the electronic device is capable of splitting all the elements according to the requirement data.
Specifically, the requirement data marks the role, keyword, class attribute and the like of the required element.
For example: when the requirement data comprises an input box, the corresponding keyword is input, and when the requirement data comprises a button, the corresponding keyword is click.
And S13, determining a classification label according to the demand data.
In at least one embodiment of the invention, the form of the category label may be custom configured.
Specifically, the classification tag has 3 attributes: ID tag, NAME tag, CLASS tag.
Wherein the ID tag has a non-repeatable and uniquely identifiable characteristic; the NAME label can be identified by NAME, is convenient to distinguish and has repeatability and belongs to a NAME sign; the CLASS label is used to point to a CLASS in the style sheet and has repeatability and belongs to a classification flag.
For example: when the classification label is a class label, in < div class ═ exp1 exp2 exp3">, div uses three class classes of exp1, exp2 and exp3, and the number is not limited, and only space is needed to separate each class name.
In at least one embodiment of the present invention, in a web page designed in an HTML language, for different requirement data, a corresponding classification tag is provided in a directory tree corresponding to the web page.
For example: corresponding to the "search" requirement data, in the directory tree corresponding to the web page, the corresponding classification tag may include: ID tag form ID, NAME tag "form" NAME, and CLASS tag "/s" CLASS.
Through the embodiment, the electronic equipment can determine the classification label corresponding to the demand data according to different demand data, and the element is conveniently split subsequently according to different classification labels.
S14, splitting all the elements according to the classification labels.
In at least one embodiment of the present invention, the electronic device, according to the classification tag, splitting the all elements includes:
and the electronic equipment determines a regular expression corresponding to the classification label, and splits all the elements by the regular expression.
The regular expression is used for retrieving and replacing texts conforming to a certain pattern (rule), and belongs to a screening logic.
Specifically, the electronic device uses the classification label as a code component of the regular expression, so as to extract an element corresponding to the classification label based on the regular expression.
Further, the electronic device classifies and extracts all the elements according to each classification label.
For example: the electronic equipment classifies the elements with input as the classification labels into one class, classifies the elements with click as the classification labels into one class, and classifies the elements with clear as the classification labels into one class so as to split all the elements.
Through the embodiment, all the elements can be effectively classified, and then the elements are split.
And S15, packaging the split elements into objects.
In at least one embodiment of the present invention, the electronic device packages the split element as an object, that is, packages the split element as a code that can be reused, so as to make a subsequent direct call.
In at least one embodiment of the present invention, the electronic device packaging the split element as an object includes:
and the electronic equipment exports the split elements into texts and names the texts, and further saves the named texts as the objects.
Specifically, the electronic device imports the split element into a notebook, and replaces the extension of the split element with a text format of ". txt", and further, the electronic device saves the element with the replaced extension, and further encapsulates the split element as the object.
Through the embodiment, the split elements can be quickly packaged as objects, so that the packaged elements can be reused, and the efficiency is improved for subsequent tests.
In at least one embodiment of the present invention, the naming of the text by the electronic device specifically includes:
the electronic equipment acquires the classification label of the text, further names the text by the classification label, and sends prompt information when repeated naming occurs.
For example: the electronic device sets a page name as login, and names the login page with the name attribute of the element, then generates an object login _ username ═ (by.xpath, '/input [ @ name ═ username "]') login _ password ═ (by.xpath, '// input [ @ name ═ password" ]').
Further, when duplicate naming occurs, the electronic device may issue a prompt message for the purpose of uniquely identifying a text by a naming.
The manner of sending the prompt message by the electronic device may include, but is not limited to, one or a combination of the following manners:
(1) and popping up a prompt box on the screen of the electronic equipment, wherein the prompt box displays the prompt information.
(2) The electronic equipment carries out voice prompt, and the content of voice can be configured by self-definition, such as 'the name exists' and the like.
Through the implementation mode, the situation that the text is repeatedly named can be avoided, and one text is uniquely determined through one name.
In at least one embodiment of the present invention, after packaging the split element as an object, the method further comprises:
when a test task is received, the electronic device determines a test environment of the test task, further converts the object into a code corresponding to the test environment, and executes the test task with the code.
In particular, the test environment corresponds to the language applied, for example: java language, Python language, etc.
Through the embodiment, the classified objects can be directly used for testing, the testing time is effectively saved, and convenience is brought to testers for developing codes.
According to the technical scheme, the test page can be automatically acquired when the packaging instruction is received, all elements of the test page are comprehensively captured by adopting a web crawler technology, the demand data are further determined from the packaging instruction, the classification tags are determined according to the demand data, all the elements are further split according to the classification tags, and the split elements are packaged as objects, so that the page elements are effectively classified, the classified elements can be used for testing, and the execution efficiency is improved.
Fig. 2 is a functional block diagram of a page element packaging apparatus according to a preferred embodiment of the present invention. The page element packaging apparatus 11 includes an acquisition unit 110, a fetching unit 111, a determination unit 112, a splitting unit 113, a packaging unit 114, a conversion unit 115, and an execution unit 116. The module/unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When a package instruction is received, the obtaining unit 110 obtains a test page.
In at least one embodiment of the present invention, an HTML (HyperText Markup Language) is a programming Language necessary for making a Web page, and the Web page is mostly designed in the market by using the HTML, and the essence of the Web page is the HyperText Markup Language, and by combining with other Web (internet) technologies (such as scripting Language, public gateway interface, components, and the like), a powerful Web page can be created.
Therefore, the test page in this embodiment is a web page designed in HTML language, so that the present disclosure has higher practicability.
In at least one embodiment of the present invention, the test page may include a main page, a navigation page, a merchandise page, and the like.
In at least one embodiment of the present invention, the obtaining, when receiving the package instruction, the obtaining unit 110 obtains the test page, including:
the obtaining unit 110 obtains a page address from the package instruction, and further, the obtaining unit 110 locates the test page according to the page address.
In at least one embodiment of the present invention, the package instructions may include, but are not limited to, one or more of the following: page address, demand data, etc.
In this embodiment, the obtaining unit 110 links to a webpage corresponding to the page address, and uses the linked webpage as the test page.
By the implementation method, the test page can be accurately acquired, so that elements can be captured from the test page subsequently.
The crawling unit 111 crawls all elements of the test page by using a web crawler technology.
In at least one embodiment of the invention, the all elements refer to html element sets for constructing page frames.
Specifically, all of the elements may include, but are not limited to, combinations of one or more of the following:
html script, body, head, font, table, tr, td, a link, picture link, text content, etc.
In at least one embodiment of the present invention, the crawling unit 111 crawls all elements of the test page by using web crawler technology, including:
the crawling unit 111 crawls the directory tree of the test page by using a web crawler technology, and further, the crawling unit 111 determines all subdirectories in the directory tree, and takes an element of each subdirectory in all subdirectories as all elements of the test page.
The web crawler (web crawler) is also called a web spider, and is a technology for automatically crawling a directory tree of any page according to a certain rule.
Specifically, in this embodiment, the fetching policy of the directory tree of the test page may include, but is not limited to: Depth-First-Search (DFS), Breadth-First Search (BFS), and Best-First Search (Best-First Search), among others.
In many cases, the depth-first search method may cause a problem of trapping of a crawler, and therefore, in this embodiment, the electronic device employs the breadth-first search method and the best-first search method.
In at least one embodiment of the invention, the directory tree is composed of a series of program segments, each web page has its own directory tree, and the directory trees of different web pages are different.
For example: each search engine (such as Baidu search, Google search, instant search, etc.) has its own directory tree, and the directory trees of the search engines are different.
Further, the crawling unit 111 crawls all elements of the test page by using web crawler technology.
For example: the crawling unit 111 traverses the test page by using the breadth-first search method, and the crawling unit 111 sets the link depth to be between 2 and 5. In the process of traversing the web page, the crawling unit 111 crawls a URL (Uniform Resource Locator) in the web page, uses keywords and/or tags in the URL as elements of each subdirectory, and further determines all elements of the test page.
The breadth-first search strategy is a graph search calculation strategy. Briefly, the breadth-first search strategy is to traverse the nodes of the tree along its width, starting at the root node, and if a target is found, the search terminates.
Through the implementation mode, all elements in the test page can be captured, and the situation that the elements are not captured is avoided.
The determination unit 112 determines the demand data from the package instructions.
In at least one embodiment of the invention, the determination unit 112 may directly retrieve the demand data from the package instructions.
In at least one embodiment of the present invention, the splitting unit 113 is capable of splitting all the elements according to the requirement data.
Specifically, the requirement data marks the role, keyword, class attribute and the like of the required element.
For example: when the requirement data comprises an input box, the corresponding keyword is input, and when the requirement data comprises a button, the corresponding keyword is click.
The determination unit 112 determines a classification label according to the demand data.
In at least one embodiment of the invention, the form of the category label may be custom configured.
Specifically, the classification tag has 3 attributes: ID tag, NAME tag, CLASS tag.
Wherein the ID tag has a non-repeatable and uniquely identifiable characteristic; the NAME label can be identified by NAME, is convenient to distinguish and has repeatability and belongs to a NAME sign; the CLASS label is used to point to a CLASS in the style sheet and has repeatability and belongs to a classification flag.
For example: when the classification label is a class label, in < div class ═ exp1 exp2 exp3">, div uses three class classes of exp1, exp2 and exp3, and the number is not limited, and only space is needed to separate each class name.
In at least one embodiment of the present invention, in a web page designed in an HTML language, for different requirement data, a corresponding classification tag is provided in a directory tree corresponding to the web page.
For example: corresponding to the "search" requirement data, in the directory tree corresponding to the web page, the corresponding classification tag may include: ID tag form ID, NAME tag "form" NAME, and CLASS tag "/s" CLASS.
Through the above embodiment, the determining unit 112 can determine the classification label corresponding to the demand data according to different demand data, so as to facilitate the subsequent splitting of the element according to different classification labels.
The splitting unit 113 splits all the elements according to the classification tags.
In at least one embodiment of the present invention, the splitting unit 113 splits all the elements according to the classification tags, including:
the splitting unit 113 determines a regular expression corresponding to the classification label, and further, the splitting unit 113 splits all the elements by using the regular expression.
The regular expression is used for retrieving and replacing texts conforming to a certain pattern (rule), and belongs to a screening logic.
Specifically, the splitting unit 113 uses the classification label as a code component of the regular expression, so as to extract an element corresponding to the classification label based on the regular expression.
Further, the splitting unit 113 classifies and extracts all the elements according to each classification label.
For example: the splitting unit 113 classifies the elements with input as the classification label into one class, classifies the elements with click as the classification label into one class, and classifies the elements with clear as the classification label into one class, so as to split all the elements.
Through the embodiment, all the elements can be effectively classified, and then the elements are split.
The packaging unit 114 packages the split elements as objects.
In at least one embodiment of the present invention, the encapsulating unit 114 encapsulates the split element as an object, that is, encapsulates the split element as reusable code for subsequent direct invocation.
In at least one embodiment of the present invention, the encapsulating unit 114 encapsulates the split element as an object, including:
the packaging unit 114 derives the split elements into a text, names the text, and further, the packaging unit 114 stores the named text as the object.
Specifically, the packaging unit 114 introduces the split element into a notebook, and replaces the extension of the split element with a text format of ". txt", and further, the packaging unit 114 stores the element with the replaced extension, and the electronic device further packages the split element as the object.
Through the embodiment, the split elements can be quickly packaged as objects, so that the packaged elements can be reused, and the efficiency is improved for subsequent tests.
In at least one embodiment of the present invention, the naming of the text by the packaging unit 114 specifically includes:
the packaging unit 114 obtains the classification label of the text, further, the packaging unit 114 names the text with the classification label, and when repeated naming occurs, the packaging unit 114 sends out prompt information.
For example: the wrapper unit 114 sets a page name, login, and names the login page with the name attribute of the element, and then generates an object, login _ username ═ (by.xpath, '/input [ @ name ═ username "]') login _ password ═ by.xpath, '/input [ @ name ═ password" ]').
Further, when duplicate naming occurs, the encapsulation unit 114 may issue a prompt message for the purpose of uniquely identifying a text by a naming.
The manner of sending the prompt message by the packaging unit 114 may include, but is not limited to, one or a combination of the following manners:
(1) the packaging unit 114 pops up a prompt box on the screen of the electronic device, and the prompt box displays the prompt information.
(2) The packaging unit 114 performs voice prompt, and the content of the voice can be configured by self-definition, such as "the name already exists" and the like.
Through the implementation mode, the situation that the text is repeatedly named can be avoided, and one text is uniquely determined through one name.
In at least one embodiment of the present invention, after packaging the split element as an object, the method further comprises:
when a test task is received, the determining unit 112 determines a test environment of the test task, further, the converting unit 115 converts the object into a code corresponding to the test environment, and further, the executing unit 116 executes the test task with the code.
In particular, the test environment corresponds to the language applied, for example: java language, Python language, etc.
Through the embodiment, the classified objects can be directly used for testing, the testing time is effectively saved, and convenience is brought to testers for developing codes.
According to the technical scheme, the test page can be automatically acquired when the packaging instruction is received, all elements of the test page are comprehensively captured by adopting a web crawler technology, the demand data are further determined from the packaging instruction, the classification tags are determined according to the demand data, all the elements are further split according to the classification tags, and the split elements are packaged as objects, so that the page elements are effectively classified, the classified elements can be used for testing, and the execution efficiency is improved.
Fig. 3 is a schematic structural diagram of an electronic device implementing a page element encapsulation method according to a preferred embodiment of the present invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program, such as a page element wrapper program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the above-mentioned various page element packaging method embodiments, such as steps S10, S11, S12, S13, S14, S15 shown in fig. 1.
Alternatively, the processor 13, when executing the computer program, implements the functions of the modules/units in the above device embodiments, for example: when a packaging instruction is received, a test page is obtained; capturing all elements of the test page by adopting a web crawler technology; determining demand data from the packaging instructions; determining a classification label according to the demand data; splitting all the elements according to the classification labels; and packaging the split elements into objects.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an acquisition unit 110, a grasping unit 111, a determination unit 112, a splitting unit 113, a packaging unit 114, a conversion unit 115, and an execution unit 116.
The memory 12 can be used for storing the computer programs and/or modules, and the processor 13 implements various functions of the electronic device 1 by running or executing the computer programs and/or modules stored in the memory 12 and calling data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, etc.) created according to the use of the electronic device, etc. Further, the memory 12 may include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other non-volatile solid state storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory having a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
In conjunction with fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a page element encapsulation method, and the processor 13 executes the plurality of instructions to implement: when a packaging instruction is received, a test page is obtained; capturing all elements of the test page by adopting a web crawler technology; determining demand data from the packaging instructions; determining a classification label according to the demand data; splitting all the elements according to the classification labels; and packaging the split elements into objects.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A page element encapsulation method, characterized in that the method comprises:
when a packaging instruction is received, a test page is obtained;
capturing all elements of the test page by adopting a web crawler technology;
determining demand data from the packaging instructions;
determining a classification label according to the demand data;
splitting all the elements according to the classification labels;
and packaging the split elements into objects.
2. The page element encapsulation method of claim 1, wherein said obtaining a test page upon receiving an encapsulation instruction comprises:
acquiring a page address from the packaging instruction;
and positioning the test page according to the page address.
3. The page element encapsulation method of claim 1, wherein said crawling all elements of said test page using web crawler technology comprises:
adopting a web crawler technology to capture a directory tree of the test page;
determining all subdirectories in the directory tree;
and taking the elements of each subdirectory in all subdirectories as all elements of the test page.
4. The page element encapsulation method according to claim 1, wherein said splitting said all elements according to said classification tag comprises:
determining a regular expression corresponding to the classification label;
splitting all the elements by the regular expression.
5. The page element encapsulation method according to claim 1, wherein said encapsulating the split element as an object comprises:
exporting the split elements into texts;
naming the text;
and saving the named text as the object.
6. The page element encapsulation method according to claim 5, wherein said naming said text comprises:
acquiring a classification label of the text;
naming the text with the classification label;
when repeated naming occurs, prompt information is sent out.
7. The page element encapsulation method according to claim 1, wherein after encapsulating the split element as an object, the method further comprises:
when a test task is received, determining a test environment of the test task;
converting the object into code corresponding to the test environment;
executing the test task with the code.
8. A page element encapsulation apparatus, the apparatus comprising:
the acquisition unit is used for acquiring a test page when a packaging instruction is received;
the grabbing unit is used for grabbing all elements of the test page by adopting a web crawler technology;
the determining unit is used for determining the demand data from the packaging instruction;
the determining unit is further configured to determine a classification label according to the demand data;
the splitting unit is used for splitting all the elements according to the classification labels;
and the packaging unit is used for packaging the split elements into objects.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the page element encapsulation method of any of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executable by a processor in an electronic device to implement the page element encapsulation method of any one of claims 1 to 7.
CN201910833456.9A 2019-09-04 2019-09-04 Page element packaging method and device, electronic equipment and storage medium Pending CN110764994A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910833456.9A CN110764994A (en) 2019-09-04 2019-09-04 Page element packaging method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910833456.9A CN110764994A (en) 2019-09-04 2019-09-04 Page element packaging method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110764994A true CN110764994A (en) 2020-02-07

Family

ID=69329375

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910833456.9A Pending CN110764994A (en) 2019-09-04 2019-09-04 Page element packaging method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110764994A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666220A (en) * 2020-06-30 2020-09-15 成都新潮传媒集团有限公司 Method and device for generating Web page object test file
WO2022179128A1 (en) * 2021-02-25 2022-09-01 深圳壹账通智能科技有限公司 Crawler-based data crawling method and apparatus, computer device, and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666220A (en) * 2020-06-30 2020-09-15 成都新潮传媒集团有限公司 Method and device for generating Web page object test file
WO2022179128A1 (en) * 2021-02-25 2022-09-01 深圳壹账通智能科技有限公司 Crawler-based data crawling method and apparatus, computer device, and storage medium

Similar Documents

Publication Publication Date Title
Hargreaves et al. An automated timeline reconstruction approach for digital forensic investigations
CN103888490B (en) A kind of man-machine knowledge method for distinguishing of full automatic WEB client side
CN104036011B (en) Webpage element display method and browser device
US20150033331A1 (en) System and method for webpage analysis
US20150295942A1 (en) Method and server for performing cloud detection for malicious information
CN109376291B (en) Website fingerprint information scanning method and device based on web crawler
CN106897251B (en) Rich text display method and device
US20130073536A1 (en) Indexing of urls with fragments
CN108021598B (en) Page extraction template matching method and device and server
US20150227276A1 (en) Method and system for providing an interactive user guide on a webpage
FR3018620A3 (en) CREATING RULES FOR USE IN THIRD PARTY MANAGEMENT SYSTEMS
US8751930B2 (en) Seamlessly sharing and reusing knowledge between an administrator console and user interaction
US20150089415A1 (en) Method of processing big data, apparatus performing the same and storage media storing the same
CN107294918B (en) Phishing webpage detection method and device
WO2014153457A1 (en) Merging web page style addresses
CN110321504B (en) Page processing method and device
CN106547782A (en) The acquisition methods and device of log information
CA2786418C (en) Identifying equivalent javascript events
CN105868290A (en) Search result presentation method and apparatus
CN110764994A (en) Page element packaging method and device, electronic equipment and storage medium
CN112818200A (en) Data crawling and event analyzing method and system based on static website
KR102009020B1 (en) Method and apparatus for providing website authentication data for search engine
CN105808605B (en) A kind of search log merging method and system
CN109558123B (en) Method for converting webpage into electronic book, electronic equipment and storage medium
CN104778232B (en) Searching result optimizing method and device based on long query

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination