CN111258904A - Webpage element testing method and related device - Google Patents
Webpage element testing method and related device Download PDFInfo
- Publication number
- CN111258904A CN111258904A CN202010059138.4A CN202010059138A CN111258904A CN 111258904 A CN111258904 A CN 111258904A CN 202010059138 A CN202010059138 A CN 202010059138A CN 111258904 A CN111258904 A CN 111258904A
- Authority
- CN
- China
- Prior art keywords
- tested
- page
- test
- total
- url address
- 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
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 151
- 230000009471 action Effects 0.000 claims description 25
- 238000000034 method Methods 0.000 claims description 23
- 238000004590 computer program Methods 0.000 claims description 11
- 238000001914 filtration Methods 0.000 claims description 2
- 238000010586 diagram Methods 0.000 description 12
- 230000006870 function Effects 0.000 description 7
- BUGBHKTXTAQXES-UHFFFAOYSA-N Selenium Chemical compound [Se] BUGBHKTXTAQXES-UHFFFAOYSA-N 0.000 description 6
- 229910052711 selenium Inorganic materials 0.000 description 6
- 239000011669 selenium Substances 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 230000008569 process Effects 0.000 description 3
- 238000012790 confirmation Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000035484 reaction time Effects 0.000 description 2
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000000391 smoking effect Effects 0.000 description 1
- 238000010998 test method Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
- G06F16/9566—URL specific, e.g. using aliases, detecting broken or misspelled links
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The embodiment of the invention provides a webpage element testing method and a related device, and relates to the technical field of webpage testing. The webpage element testing method comprises the following steps: receiving a first URL address, wherein the first URL address corresponds to a page to be tested; opening a page to be tested according to the first URL address; when the page to be tested is in a preset page, searching elements related to the business and elements related to the non-business in the page to be tested to obtain an element set to be tested; and sequentially testing each element in the element set to be tested to obtain a test result. The webpage element testing method and the related device provided by the embodiment of the invention can improve the testing coverage rate of the webpage elements.
Description
Technical Field
The invention relates to the technical field of webpage testing, in particular to a webpage element testing method and a related device.
Background
In a traditional end-to-end test of a WEB (world wide WEB) system, an automatic test case is generally written, and then whether an application function meets requirements or not is determined according to a case execution result. Under this strategy, only a small part of elements in the page will be operated, resulting in a low test element coverage.
Disclosure of Invention
In view of the above, the present invention provides a method and a related apparatus for testing web page elements, which can improve the test coverage of web page elements.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment provides a method for testing web page elements, where the method includes:
receiving a first Uniform Resource Locator (URL) address, wherein the first URL address corresponds to a page to be tested;
opening the page to be tested according to the first URL address;
when the page to be tested is in a preset page, searching elements related to the business and elements related to the non-business in the page to be tested to obtain an element set to be tested;
and sequentially testing each element in the element set to be tested to obtain a test result.
In an optional embodiment, the step of searching the elements related to the business and the elements related to the non-business in the page to be tested to obtain the set of elements to be tested includes:
acquiring preset identification information, wherein the preset identification information comprises tag information, attribute information and attribute values which are associated with the service-related element and the non-service-related element;
and searching elements corresponding to the label information, the attribute information and the attribute values one by one according to the label information, the attribute information and the attribute values to obtain an element set to be tested.
In an optional embodiment, a corresponding relationship between the preset identification information and the element type of the element, and a corresponding relationship between the element type and the test action are configured in advance;
the step of sequentially testing each element in the element set to be tested to obtain a test result comprises the following steps:
acquiring a target element from an element set to be tested;
determining the element type of the target element according to the preset identification information of the target element;
determining a test action corresponding to the target element according to the element type of the target element;
executing the test action, and acquiring an HTTP (Hyper Text transfer protocol) request result and a console log corresponding to the target element;
traversing each element in the element set to be tested, and acquiring a total HTTP request result and a total control console log, wherein the total HTTP request result and the total control console log comprise an HTTP request result and a control console log of each element;
and generating the test result according to the total HTTP request result and the total console log.
In an optional embodiment, the step of sequentially testing each element in the element set to be tested to obtain a test result further includes:
executing the test action, and acquiring an error log and a request record corresponding to the target element;
traversing each element in the element set to be tested, and acquiring a total error log and a total request record, wherein the total error log and the total request record comprise an error log and a request record of each element;
and generating the test result according to the total HTTP request result, the total console log, the total error log and the total request record.
In an optional embodiment, the first URL address is stored in a test queue, and the method further includes:
executing the test action to acquire a second URL address;
storing the second URL address in the test queue;
when the test of each element in the element set to be tested is completed, opening a new page to be tested according to the second URL address;
and replacing the new page to be tested with the page to be tested, and repeating the steps until all URL addresses in the test queue are accessed.
In an alternative embodiment, the method further comprises:
and filtering the sensitive elements in the element set to be tested according to a preset element filter.
In a second aspect, an embodiment provides a web page element testing apparatus, including:
the receiving module is used for receiving a first URL address, and the first URL address corresponds to a page to be tested;
the page opening module is used for opening the page to be tested according to the first URL address;
the element searching module is used for searching elements related to business and elements related to non-business in the page to be tested when the page to be tested is in a preset page to obtain an element set to be tested;
and the test module is used for sequentially testing each element in the element set to be tested to obtain a test result.
In an alternative embodiment, the element lookup module comprises:
an obtaining unit, configured to obtain preset identification information, where the preset identification information includes tag information, attribute information, and an attribute value associated with an element related to the service and an element related to the non-service;
and the searching unit is used for searching the elements which correspond to the label information, the attribute information and the attribute value one by one according to the label information, the attribute information and the attribute value to obtain an element set to be tested.
In a third aspect, an embodiment provides an electronic device, including a processor and a memory, where the memory stores a computer program capable of being executed by the processor, and the processor can execute the computer program to implement the method of any one of the foregoing embodiments.
In a fourth aspect, embodiments provide a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method according to any of the preceding embodiments.
According to the webpage element testing method and the related device provided by the embodiment of the invention, the first URL address is received, and corresponds to the page to be tested; opening a page to be tested according to the first URL address; when the page to be tested is in a preset page, searching elements related to the business and elements related to the non-business in the page to be tested to obtain an element set to be tested; and sequentially testing each element in the element set to be tested to obtain a test result. Therefore, the webpage element testing method provided by the invention can test the elements related to the business and the elements related to the non-business in the page to be tested, can test all the elements in the page to be tested, and can greatly improve the test coverage rate of the elements.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic diagram illustrating an application environment of an electronic device according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for testing web page elements according to an embodiment of the present invention;
FIG. 4 shows a sub-flowchart of step S303 shown in FIG. 3;
FIG. 5 is a sub-flowchart of step S304 shown in FIG. 3;
fig. 6 is a schematic structural diagram illustrating a web page element testing apparatus according to an embodiment of the present invention;
fig. 7 shows a schematic structural diagram of the element lookup module shown in fig. 6.
Icon: 100-an electronic device; 110-a memory; 120-a processor; 130-a communication module; 140-web page element testing means; 141-a receiving module; 142-a web page opening module; 143-element finding module; 1431-an acquisition unit; 1432-lookup unit; 144-a test module; 200-back end server.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It is noted that relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Referring to fig. 1, a schematic diagram of an implementable application environment of an electronic device 100 according to an embodiment of the present invention is provided, in which the electronic device 100 is communicatively connected to a backend server 200, the electronic device 100 is used for taking charge of displaying an HTML (hypertext markup Language) page, and the backend server 200 is used for providing various service supports (e.g., data services). The electronic device 100 may perform page parsing using Java language, and may perform a test on the browser using selenium as a test tool.
In the present embodiment, the electronic device 100 may be, but is not limited to, a notebook computer, a desktop computer, or other electronic devices with processing capabilities.
Referring to fig. 2, a schematic diagram of an implementable structure of the electronic device 100 according to the embodiment of the present invention is provided, where the electronic device 100 includes a memory 110, a processor 120, a communication module 130, and the like, and these components communicate with each other through one or more communication buses/signal lines.
The memory 110 is used to store programs or data. The Memory 110 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an erasable Read-Only Memory (EPROM), an electrically erasable Read-Only Memory (EEPROM), and the like.
The processor 120 is used to read/write data or programs stored in the memory 110 and perform corresponding functions. For example, when the computer program stored in the memory 110 is executed by the processor 120, the web page element testing method disclosed by the embodiment of the invention can be realized.
The communication module 130 is used for establishing a communication connection between the electronic device 100 and the backend server 200 through a network, and for transceiving data through the network.
It should be understood that the structure shown in fig. 2 is only a schematic structural diagram of the electronic device 100, and the electronic device 100 may also include more or fewer components than shown in fig. 2, or have a different configuration than shown in fig. 2. The components shown in fig. 2 may be implemented in hardware, software, or a combination thereof.
The present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by the processor 120, implements the web page element testing method according to any one of the foregoing embodiments. The computer readable storage medium may be, but is not limited to, various media that can store program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a magnetic or optical disk, etc.
Fig. 3 is a schematic flow chart of a web page element testing method according to an embodiment of the present invention. It should be noted that, the web page element testing method provided in the embodiment of the present invention is not limited by fig. 3 and the following specific sequence, and it should be understood that, in other embodiments, the sequence of some steps in the web page element testing method provided in the embodiment of the present invention may be interchanged according to actual needs, or some steps in the web page element testing method may be omitted or deleted. The web page element testing method can be applied to the electronic device 100 shown in fig. 1, and the specific flow shown in fig. 3 will be described in detail below.
Step S301, receiving a first URL address, wherein the first URL address corresponds to a page to be tested.
In this embodiment, the electronic device 100 may be provided with a user login processor 120, and the user login processor 120 is configured to provide a login function to the user. That is, when the user performs the web page element test, the user needs to log in through the log-in processor 120 and succeed in the log-in, so as to perform the web page element test.
In this embodiment, the first URL address may be stored in the memory 110 of the electronic device 100 in advance, or may be obtained by the electronic device 100 in response to an input operation by a user before the test.
The URL address is also called a web page address, and is an address of a standard resource on the internet, and each file on the internet has a unique URL, which includes information indicating the location of the file and how the browser should handle it.
Step S302, opening a page to be tested according to the first URL address.
In this embodiment, the electronic device 100 accesses the obtained first URL address to open the page to be tested using the selenium test tool.
In this embodiment, before the page to be tested is opened, the browser needs to be started, and after the browser is started, the obtained first URL address is accessed through the selenium test tool, and the browser is operated to display the page to be tested.
Step S303, when the page to be tested is in the preset page, searching the elements related to the business and the elements related to the non-business in the page to be tested to obtain the element set to be tested.
In this embodiment, after accessing the obtained first URL address by using the selenium test tool, the electronic device 100 may detect whether the currently displayed page of the browser is a page to be tested, and if the currently displayed page of the browser is a preset page, it is determined that the page to be tested is successfully opened; and if the current displayed page of the browser is not the preset page, judging that the page to be tested fails to be opened.
It can be understood that if the preset page is a login page, after the obtained first URL address is accessed by using a selenium test tool, if the currently displayed page of the browser is the login page, it is determined that the page to be tested is successfully opened; and if the current displayed page of the browser is not a login page, is a blank page or other non-login pages and the like, judging that the page to be tested fails to be opened.
In the embodiment, different pages to be tested, the business related elements and the non-business related elements of each page to be tested are different. For example, when the page to be tested is a login page, the account input box and the confirmation button in the login page are elements related to business, and the advertisement link and the like in the login page are elements related to non-business. When the page to be tested is the navigation display page, a search input box, a search confirmation button, a list and other web page links and the like of the navigation display page are elements related to the business.
And step S304, sequentially testing each element in the element set to be tested to obtain a test result.
In this embodiment, the electronic device 100 sequentially tests each element in the set of elements to be tested, and provides a usability test report of each element in the page to be tested to the user according to the test result.
In this embodiment, a page smoking test method is adopted to replace the conventional manual script writing, and the automated test of the automated test case is executed. The working time of a user can not be occupied, the test is automatically carried out in the rest time of the user, and the labor cost can be reduced. And the elements related to the service and the elements related to the non-service in the page to be tested can be tested, and the test coverage rate can be improved without increasing the workload of a user.
Referring to fig. 4, for an implementation manner of the lookup element provided in the embodiment of the present invention, step S303 further includes the following sub-steps:
in the substep S401, preset identification information is obtained, where the preset identification information includes tag information, attribute information, and attribute values associated with elements related to a service and elements related to a non-service.
In the embodiment, the memory 110 of the electronic device 100 stores the preset identification information in advance, and the processor 120 obtains the preset identification information stored in advance from the memory 110 when the web page element test is performed.
It will be appreciated that the tag information, attribute information and attribute values of different business related elements and different non-business related elements are different. That is, the tag information, the attribute information, and the attribute value associated with the element related to the first service are first tag information, first attribute information, and a first attribute value, the tag information, the attribute information, and the attribute value associated with the element related to the second service are second tag information, second attribute information, and a second attribute value, the tag information, the attribute information, and the attribute value associated with the element related to the first non-service are third tag information, third attribute information, and a third attribute value, and the tag information, the attribute information, and the attribute value associated with the element related to the second non-service are fourth tag information, fourth attribute information, and a fourth attribute value.
The first service-related element, the second service-related element, the first non-service-related element and the second non-service-related element are different elements, so that the first tag information, the second tag information, the third tag information and the fourth tag information are different tag information, the first attribute information, the second attribute information, the third attribute information and the fourth attribute information are different attribute information, and the first attribute value, the second attribute value, the third attribute value and the fourth attribute value are different attribute values.
And a substep S402 of searching elements corresponding to the label information, the attribute information and the attribute value one by one according to the label information, the attribute information and the attribute value to obtain an element set to be tested.
In this embodiment, the electronic device 100 accesses the obtained first URL address through the selenium test tool, starts to parse the page to be tested after the page to be tested is successfully opened, and searches for elements corresponding to the tag information, the attribute information, and the attribute value one to one according to the pre-stored tag information, attribute information, and attribute value to obtain the element set to be tested.
Referring to fig. 5, for an implementation manner of the test element provided in the embodiment of the present invention, step S304 further includes the following sub-steps:
and a substep S501, obtaining a target element from the element set to be tested.
In this embodiment, the electronic device 100 randomly selects one element from all elements in the element set to be tested as the target element.
And a substep S502 of determining the element type of the target element according to the preset identification information of the target element.
In this embodiment, the electronic device 100 may pre-configure a corresponding relationship between the preset identification information and the element type of the element. That is, the preset identification information associated with the elements of different element types is different, if the tag information, attribute information, and attribute value associated with the element of which the element type is a form are form tag information, form attribute information, and form attribute value, if the tag information, attribute information, and attribute value associated with the element of which the element type is a list are list tag information, list attribute information, and list attribute value, if the tag information, attribute information, and attribute value associated with the element of which the element type is a button are button tag information, button attribute information, and button attribute value, if the tag information, attribute information, and attribute value associated with the element of which the element type is a link are link tag information, link attribute information, and link attribute value, if the tag information, attribute information, and attribute value associated with the element of which the element type is a selection box are selection box tag information, list attribute information, and list attribute value, And selecting the attribute information and the attribute value of the selection frame, and if the label information, the attribute information and the attribute value associated with the element of which the element type is the drop-down frame are the tag information, the attribute information and the attribute value of the drop-down frame.
And a substep S503, determining the test action corresponding to the target element according to the element type of the target element.
In this embodiment, the electronic device 100 may pre-configure the corresponding relationship between the element type and the test action. If the target element is a form, determining that the test action corresponding to the target element is a form filling; if the target element is a list, determining a test action corresponding to the target element as an element in a click list; if the target element is a button, determining a test action corresponding to the target element as a click; if the target element is a link, determining a test action corresponding to the target element as a click; if the target element is the selection frame, determining the test action corresponding to the target element as a click; and if the target element is a drop-down box, determining the test action corresponding to the target element as a click and selecting one item.
And a substep S504 of executing the test action and acquiring the HTTP request result and the console log corresponding to the target element.
In this embodiment, the console log is monitored by a Chrome debug tool, and the console log includes vulnerability information and error information generated when the processor 120 executes a computer program to implement the web page element testing method. The HTTP request result comprises a loading result when the browser loads a data packet corresponding to the page element to be tested, and the loading result comprises loading success and loading failure. If the advertisement link of the page to be tested is clicked, if the browser can send the HTTP request and can receive the fed back HTTP result, the browser loads and successfully displays the advertisement webpage corresponding to the advertisement link, and the loading is indicated to be successful. If the browser cannot send the HTTP request or can send the HTTP request but does not receive the HTTP result of the feedback, the browser cannot load and cannot display the advertisement webpage corresponding to the advertisement link, and loading failure is indicated.
And a substep S505, traversing each element in the element set to be tested, and acquiring a total HTTP request result and a total console log, wherein the total HTTP request result and the total console log comprise the HTTP request result and the console log of each element.
In this embodiment, after selecting an element operation target element from the element set to be tested for testing, if the remaining element set to be tested has no undetected element, the electronic device 100 proceeds to substep S506; if the remaining element set to be tested has undetected elements, the contents of the substeps S502 to S504 are repeated to obtain the total HTTP request result and the total console log. Since the HTTP request result and the console log corresponding to each element may not be the same, the total HTTP request result and the total console log include the HTTP request result and the console log of each element.
And a substep S506 of generating a test result according to the total HTTP request result and the total console log.
In this embodiment, the electronic device 100 generates a test result according to the vulnerability information, the error information, the loading result, and the like, where the test result includes an availability conclusion that the element type is a form element, an availability conclusion that the element type is a list element, an availability conclusion that the element type is a button element, an availability conclusion that the element type is a link, an availability conclusion that the element type is a selection box element, and an availability conclusion that the element type is a drop-down box element.
In this embodiment, the elements included in the element set to be tested may be at least one of a form, a list, a button, a link, a selection box, and a drop-down box, and the type and number of the elements included in the element set to be tested are determined by a specific page to be tested, which is not limited herein.
Further, in this embodiment, when the test action is executed, an error log and a request record corresponding to the target element may also be obtained; traversing each element in the element set to be tested, and acquiring a total error log and a total request record, wherein the total error log and the total request record comprise an error log and a request record of each element; and generating a test result according to the total HTTP request result, the total control station log, the total error log and the total request record.
The ERROR log is an ERROR level log, the request record comprises request time information, and test results such as test time, reaction time and the like can be obtained according to the total ERROR log and the total request record. I.e. the test results also include test time, reaction time, etc.
Further, in this embodiment, when the test action is executed, a second URL address may be acquired; storing the second URL address in a test queue; when the test of each element in the element set to be tested is completed, opening a new page to be tested according to the second URL address; and replacing the new page to be tested with the page to be tested, and repeating the contents of the step S303 and the step S304 until the URL addresses in the test queue are all accessed.
It can be understood that the first URL address is stored in the test queue, and when the test action is performed, at least one second URL address is obtained, and the electronic device 100 records the at least one second URL address and stores the at least one second URL address in the test queue, where the first URL address is different from the at least one second URL address. After all elements on the page to be tested corresponding to the first URL address are tested, a second URL address different from the first URL address is selected from the test queue to access, so that the page to be tested corresponding to the second URL address is tested until all the URL addresses in the test queue are accessed.
In this embodiment, the same URL address in the test queue only needs to be accessed once, and different URL addresses are accessed in sequence.
Further, in this embodiment, the electronic device 100 may further filter the sensitive elements in the element set to be tested according to a preset element filter, so as to filter out elements that are not desired to be tested in the page to be tested. The sensitive element may be a delete button.
In order to perform the corresponding steps in the above embodiments and various possible manners, an implementation manner of the web page element testing apparatus 140 is given below. Further, referring to fig. 6, fig. 6 is a functional block diagram of a web page element testing apparatus 140 according to an embodiment of the present invention. It should be noted that the basic principle and the generated technical effect of the web page element testing apparatus 140 provided in the present embodiment are the same as those of the above embodiments, and for the sake of brief description, no part of the present embodiment is mentioned, and corresponding contents in the above embodiments may be referred to. The web page element testing apparatus 140 includes: a receiving module 141, a web page opening module 142, an element searching module 143, and a testing module 144.
The receiving module 141 is configured to receive a first URL address, where the first URL address corresponds to a page to be tested.
It is understood that the receiving module 141 is configured to execute the content of the step S301.
The webpage opening module 142 is configured to open a page to be tested according to the first URL address.
It is understood that the web page opening module 142 is used for executing the content of the above step S302.
The element searching module 143 is configured to search, when the page to be tested is in the preset page, the elements related to the business and the elements related to the non-business in the page to be tested, so as to obtain a set of elements to be tested.
It is understood that the element search module 143 is configured to perform the content of step S303.
As shown in fig. 7, the element lookup module 143 includes an obtaining unit 1431 and a lookup unit 1432.
The obtaining unit 1431 is configured to obtain preset identification information, where the preset identification information includes tag information, attribute information, and an attribute value associated with an element related to a service and an element not related to a service.
It is understood that the obtaining unit 1431 is configured to perform the content of the sub-step S401.
The searching unit 1432 is configured to search, according to the tag information, the attribute information, and the attribute value, elements corresponding to the tag information, the attribute information, and the attribute value one to one, to obtain an element set to be tested.
It is to be understood that the look-up unit 1432 is configured to perform the content of the above sub-step S402.
The testing module 144 is configured to sequentially test each element in the element set to be tested to obtain a testing result.
It is to be understood that the testing module 144 is configured to perform the contents of step S304, sub-step S501, sub-step S502, sub-step S503, sub-step S504, sub-step S505, and sub-step S506 described above.
Alternatively, the modules may be stored in the memory 110 shown in fig. 2 in the form of software or Firmware (Firmware) or be fixed in an Operating System (OS) of the electronic device 100, and may be executed by the processor 120 in fig. 2. Meanwhile, data, codes of programs, and the like required to execute the above-described modules may be stored in the memory 110.
In summary, the embodiments of the present invention provide a method and a related apparatus for testing a web page element, where a first URL address is received, and the first URL address corresponds to a page to be tested; opening a page to be tested according to the first URL address; when the page to be tested is in a preset page, searching elements related to the business and elements related to the non-business in the page to be tested to obtain an element set to be tested; and sequentially testing each element in the element set to be tested to obtain a test result. Therefore, the webpage element testing method provided by the invention can test the elements related to the business and the elements related to the non-business in the page to be tested, can test all the elements in the page to be tested, and can greatly improve the test coverage rate of the elements.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A web page element testing method, characterized in that the method comprises:
receiving a first URL address, wherein the first URL address corresponds to a page to be tested;
opening the page to be tested according to the first URL address;
when the page to be tested is in a preset page, searching elements related to the business and elements related to the non-business in the page to be tested to obtain an element set to be tested;
and sequentially testing each element in the element set to be tested to obtain a test result.
2. The web page element testing method according to claim 1, wherein the step of finding the elements related to the business and the elements related to the non-business in the page to be tested to obtain the set of elements to be tested comprises:
acquiring preset identification information, wherein the preset identification information comprises tag information, attribute information and attribute values which are associated with the service-related element and the non-service-related element;
and searching elements corresponding to the label information, the attribute information and the attribute values one by one according to the label information, the attribute information and the attribute values to obtain an element set to be tested.
3. The web page element testing method according to claim 2, wherein a correspondence between the preset identification information and an element type of the element and a correspondence between the element type and a testing action are configured in advance;
the step of sequentially testing each element in the element set to be tested to obtain a test result comprises the following steps:
acquiring a target element from an element set to be tested;
determining the element type of the target element according to the preset identification information of the target element;
determining a test action corresponding to the target element according to the element type of the target element;
executing the test action, and acquiring an HTTP request result and a console log corresponding to the target element;
traversing each element in the element set to be tested, and acquiring a total HTTP request result and a total control console log, wherein the total HTTP request result and the total control console log comprise an HTTP request result and a control console log of each element;
and generating the test result according to the total HTTP request result and the total console log.
4. The web page element testing method of claim 3, wherein the step of sequentially testing each element in the element set to be tested to obtain a test result further comprises:
executing the test action, and acquiring an error log and a request record corresponding to the target element;
traversing each element in the element set to be tested, and acquiring a total error log and a total request record, wherein the total error log and the total request record comprise an error log and a request record of each element;
and generating the test result according to the total HTTP request result, the total console log, the total error log and the total request record.
5. The web page element testing method of claim 3, wherein the first URL address is stored in a test queue, the method further comprising:
executing the test action to acquire a second URL address;
storing the second URL address in the test queue;
when the test of each element in the element set to be tested is completed, opening a new page to be tested according to the second URL address;
and replacing the new page to be tested with the page to be tested, and repeating the steps until all URL addresses in the test queue are accessed.
6. The web page element testing method of claim 1, wherein the method further comprises:
and filtering the sensitive elements in the element set to be tested according to a preset element filter.
7. A web page element testing apparatus, the apparatus comprising:
the receiving module is used for receiving a first URL address, and the first URL address corresponds to a page to be tested;
the page opening module is used for opening the page to be tested according to the first URL address;
the element searching module is used for searching elements related to business and elements related to non-business in the page to be tested when the page to be tested is in a preset page to obtain an element set to be tested;
and the test module is used for sequentially testing each element in the element set to be tested to obtain a test result.
8. The web page element test apparatus of claim 7, wherein the element lookup module comprises:
an obtaining unit, configured to obtain preset identification information, where the preset identification information includes tag information, attribute information, and an attribute value associated with an element related to the service and an element related to the non-service;
and the searching unit is used for searching the elements which correspond to the label information, the attribute information and the attribute value one by one according to the label information, the attribute information and the attribute value to obtain an element set to be tested.
9. An electronic device comprising a processor and a memory, the memory storing a computer program executable by the processor, the processor being configured to execute the computer program to implement the method of any of claims 1-6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010059138.4A CN111258904A (en) | 2020-01-16 | 2020-01-16 | Webpage element testing method and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010059138.4A CN111258904A (en) | 2020-01-16 | 2020-01-16 | Webpage element testing method and related device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111258904A true CN111258904A (en) | 2020-06-09 |
Family
ID=70954240
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010059138.4A Pending CN111258904A (en) | 2020-01-16 | 2020-01-16 | Webpage element testing method and related device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111258904A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111913998A (en) * | 2020-09-11 | 2020-11-10 | 北京百度网讯科技有限公司 | Data processing method, device, equipment and storage medium |
CN111984891A (en) * | 2020-08-07 | 2020-11-24 | 游艺星际(北京)科技有限公司 | Page display method and device, electronic equipment and storage medium |
CN113760721A (en) * | 2021-01-13 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Page testing method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105095067A (en) * | 2014-05-21 | 2015-11-25 | 北京奇虎科技有限公司 | User interface element object identification and automatic test method and apparatus |
CN108628741A (en) * | 2018-04-10 | 2018-10-09 | 平安科技(深圳)有限公司 | Webpage test method, device, electronic equipment and medium |
CN109783388A (en) * | 2019-01-16 | 2019-05-21 | 北京金山云网络技术有限公司 | UI automated testing method, device and electronic equipment |
US20190235998A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | End-to-end user interface component testing |
CN110162457A (en) * | 2019-04-12 | 2019-08-23 | 深圳壹账通智能科技有限公司 | Test method, device, equipment and the storage medium of user interface |
-
2020
- 2020-01-16 CN CN202010059138.4A patent/CN111258904A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105095067A (en) * | 2014-05-21 | 2015-11-25 | 北京奇虎科技有限公司 | User interface element object identification and automatic test method and apparatus |
US20190235998A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | End-to-end user interface component testing |
CN108628741A (en) * | 2018-04-10 | 2018-10-09 | 平安科技(深圳)有限公司 | Webpage test method, device, electronic equipment and medium |
CN109783388A (en) * | 2019-01-16 | 2019-05-21 | 北京金山云网络技术有限公司 | UI automated testing method, device and electronic equipment |
CN110162457A (en) * | 2019-04-12 | 2019-08-23 | 深圳壹账通智能科技有限公司 | Test method, device, equipment and the storage medium of user interface |
Non-Patent Citations (1)
Title |
---|
MOONZ-WU: ""如何利用selenium来进行自动化页面测试"", 《HTTPS://WWW.CNBLOGS.COM/MOONZ-WU/ARCHIVE/2012/09/11/2680087.HTML》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111984891A (en) * | 2020-08-07 | 2020-11-24 | 游艺星际(北京)科技有限公司 | Page display method and device, electronic equipment and storage medium |
CN111913998A (en) * | 2020-09-11 | 2020-11-10 | 北京百度网讯科技有限公司 | Data processing method, device, equipment and storage medium |
CN111913998B (en) * | 2020-09-11 | 2024-06-04 | 北京百度网讯科技有限公司 | Data processing method, device, equipment and storage medium |
CN113760721A (en) * | 2021-01-13 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Page testing method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9628349B2 (en) | Interactivity analyses of web resources based on reload events | |
US9203720B2 (en) | Monitoring the health of web page analytics code | |
US8893043B2 (en) | Method and system for predictive browsing | |
JP4334232B2 (en) | Method for measuring client-side performance, computer-readable medium holding instructions therefor, and method for responding to client-side performance | |
WO2018223717A1 (en) | Webpage front-end testing method, device, system, apparatus and readable storage medium | |
US20140344907A1 (en) | Auto login method and device | |
CN111258904A (en) | Webpage element testing method and related device | |
US9026902B2 (en) | Handling unexpected responses to script executing in client-side application | |
CN107918575B (en) | Page state monitoring method and device | |
CN110011875B (en) | Dial testing method, device, equipment and computer readable storage medium | |
CN104834588B (en) | The method and apparatus for detecting resident formula cross site scripting loophole | |
CN113704110B (en) | Automatic testing method and device for user interface | |
CN103729477A (en) | Webpage data format detection method and device | |
CN108696566B (en) | Web server | |
CA2786418A1 (en) | Identifying equivalent javascript events | |
CN111431767A (en) | Multi-browser resource synchronization method and device, computer equipment and storage medium | |
CN113448835B (en) | Static resource testing method and device, electronic equipment and storage medium | |
US20050005015A1 (en) | Method, system, and computer-readable medium for managing a host session on a remote computer | |
US9104573B1 (en) | Providing relevant diagnostic information using ontology rules | |
CN109324822B (en) | PWA (public warning assistant) item detection method, computer-readable storage medium and terminal device | |
CN111367703A (en) | Troubleshooting method and device | |
CN113986603B (en) | Method and device for determining page loading abnormity reason and storage medium | |
US8874971B1 (en) | Detecting and reporting problems in a distributed resource computing system | |
US7409591B2 (en) | Method and system for managing programs for web service system | |
CN109376066A (en) | A kind of automatic test approach and device |
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 | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20200609 |