CN113094286A - Page testing method and device, storage medium and electronic equipment - Google Patents
Page testing method and device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN113094286A CN113094286A CN202110513586.1A CN202110513586A CN113094286A CN 113094286 A CN113094286 A CN 113094286A CN 202110513586 A CN202110513586 A CN 202110513586A CN 113094286 A CN113094286 A CN 113094286A
- Authority
- CN
- China
- Prior art keywords
- tested
- elements
- text
- page
- content
- 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.)
- Granted
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 90
- 238000000034 method Methods 0.000 claims abstract description 40
- 238000012216 screening Methods 0.000 claims description 18
- 238000004590 computer program Methods 0.000 claims description 13
- 238000012545 processing Methods 0.000 claims description 9
- 238000010586 diagram Methods 0.000 description 12
- 238000001545 Page's trend test Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 9
- BUGBHKTXTAQXES-UHFFFAOYSA-N Selenium Chemical compound [Se] BUGBHKTXTAQXES-UHFFFAOYSA-N 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 6
- 229910052711 selenium Inorganic materials 0.000 description 6
- 239000011669 selenium Substances 0.000 description 6
- 230000008569 process Effects 0.000 description 5
- 238000004891 communication Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 238000001914 filtration Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000004044 response Effects 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/3688—Test management for test execution, e.g. scheduling of test suites
-
- 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
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)
- Debugging And Monitoring (AREA)
- Machine Translation (AREA)
Abstract
The disclosure relates to a page testing method and device, a storage medium and an electronic device, wherein the method comprises the following steps: obtaining at least one piece of content to be tested, wherein each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested; determining a target element corresponding to the text to be tested from elements contained in the page to be tested; generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested; and testing the page based on the test instruction. The page testing efficiency can be improved.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a page testing method and apparatus, a storage medium, and an electronic device.
Background
In order to ensure the usability of the web page, the related functions of the web page are generally tested before the web page falls to the ground. Currently, automatic testing of pages can be performed through the Selenium tool, but a user needs to actively locate page elements to be operated, which can be generally accomplished through a multiple element locating method provided by the Selenium. The method has the disadvantages that on one hand, a user needs to know details of the operated page elements, such as the attributes of id, name, class, tag and the like, and applies a correct method to position the elements, for some elements with little positioning information, complex grammars such as CSS selectors or XPath and the like have to be adopted to position the elements, so that the writing test case threshold is raised, the stability of the test case is reduced, and the case execution failure can be caused by the small change of the page elements.
At present, a method for more intuitively and quickly carrying out browser automatic page testing does not exist.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present disclosure provides a page testing method, where the method includes: obtaining at least one piece of content to be tested, wherein each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested; determining a target element corresponding to the text to be tested from elements contained in the page to be tested; generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested; and testing the page based on the test instruction.
In a second aspect, the present disclosure provides a page testing apparatus, the apparatus comprising: the system comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring at least one piece of content to be tested, each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested; the determining module is used for determining a target element corresponding to the text to be tested from elements contained in the page to be tested; the generating module is used for generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested; and the testing module is used for testing the page based on the testing instruction.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, performs the steps of the method of the first aspect of the present disclosure.
In a fourth aspect, the present disclosure provides an electronic device, including a storage device having a computer program stored thereon, and a processing device configured to execute the computer program to implement the steps of the method according to the first aspect of the present disclosure.
Based on the technical scheme, the following technical effects can be at least achieved:
the target elements in the page are automatically positioned according to the text content displayed in the page to be tested, so that the corresponding test instruction can be generated through the text to be tested and the operation to be tested, the steps that a user carries out element positioning based on the element characteristics of the target page or positions the target elements through complex grammars such as CSS, XPath and the like are reduced, the generation mode of the page test instruction is simplified, and the page test efficiency can be improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flowchart illustrating a page testing method according to an exemplary disclosed embodiment
FIG. 2 is a schematic diagram illustrating a page to be tested according to an exemplary disclosed embodiment.
FIG. 3 is a schematic diagram illustrating a find element process according to an exemplary disclosed embodiment.
FIG. 4 is a block diagram illustrating a page test apparatus according to an exemplary disclosed embodiment.
FIG. 5 is a block diagram illustrating an electronic device according to an exemplary disclosed embodiment.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
Fig. 1 is a flowchart illustrating a page testing method according to an exemplary disclosed embodiment, where the method may be applied to a code library, an application program or a web page, or an electronic device loaded with the application program or the web page, as shown in fig. 1, the method includes the following steps:
s11, obtaining at least one piece of content to be tested, wherein each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is the character content displayed in the page to be tested.
A piece of content to be tested can generate a testing instruction, and the piece of content to be tested can represent that a certain operation is executed on a certain text to be tested.
Fig. 2 is a schematic diagram of a page to be tested, where a is a first drop-down box, the text content displayed in a is "recent", b is a first input box, no text content is displayed in b, and c is a first display box, the display box cannot be selected or modified by a user click, and belongs to an inoperable element, and the first display box may also be implemented based on the dependency of the first input box, and is not an independent element. In addition, d is the second drop-down box, the text content displayed in d is "any event done", e is the third drop-down box, the text content displayed in e is "total number of times", f is the fourth drop-down box, the text content displayed in f is ">", g is the second input box, and the text content displayed in g is "0".
In a conventional web page testing manner, if the fourth drop-down box needs to be clicked, the user is required to find a code of an element corresponding to the fourth drop-down box, for example, the element corresponding to the fourth drop-down box may be located by the following code: fine _ element _ by _ CSS _ selector ('div ═ is'), it is worth to be noted that the elements have different types, the different types correspond to different code types, the variety is various and difficult to memorize, and the query code is realized based on CSS syntax, so the web page test method needs a higher use threshold.
In the disclosure, based on the webpage, if the content to be tested is to click the fourth drop-down box, the text to be tested may be ">", the operation to be tested may be "click", and the code corresponding to the test content may be "ui click >. If the test content is the click first input box and the first input box has no corresponding text content, the test content can be located through the text content around the test content and is located and adjusted through the operation to be tested, for example, the text to be tested may be "closest", the operation to be tested may be "right click", the code corresponding to the test content may be "ui click right of closest", or the text to be tested may be "day", the operation to be tested may be "left click", and the code corresponding to the test content may be "ui click left of day".
Therefore, the method and the device simplify the code of the positioning element which needs to be input by the User into the code of the positioning UI (User Interface) content, so that the content input by the User is consistent with the content seen by the User, and the method and the device are more intuitive for the User.
Considering that when a page is functionally tested, multiple operations are usually required to be performed on multiple elements, more than one content to be tested can be obtained, and each content to be tested is sequentially processed to obtain multiple test instructions. For example, when the test requirement is input 7 in the first input box and input 20 in the second input box, the corresponding test contents may be "ui click right of nearest", "ui send text 7", "ui click 0", "ui send text 20" in this order.
In a possible implementation manner, when the operation to be tested includes the operation direction, the actual operation position may be a position where the element corresponding to the text to be operated is away from the preset length, and the operation direction may further include a length specified by the user, and then the actual operation position is a position where the element corresponding to the text to be operated is away from the specified length.
It should be noted that text content in the web page may be repeated, and therefore, the text to be tested may further include a number of the text, for example, 4 "open" s in the web page are total, when the text to be tested is the 1 st "open" in the web page, the text to be tested may be set to "open (0)", or "open" (i.e., a default position), then the text to be tested refers to an element that the 1 st text content in the web page is "open", and when the text to be tested is the 2 nd "open" in the web page, the text to be tested may be set to "open (1)", then the text to be tested refers to an element that the 2 nd text content in the web page is "open".
S12, determining target elements corresponding to the texts to be tested from the elements contained in the pages to be tested.
This element may be a DOM (Document Object Model) element, which is a collection of nodes or pieces of information organized in a hierarchy so that a particular piece of information can be navigated to in the DOM. In the present disclosure, the search for an element may be implemented by injecting a jQuery into a page to be tested through the Selenium.
Considering that a plurality of elements may be found based on the text to be tested, after the plurality of elements are found, the found elements can be screened to obtain more accurate elements.
In a possible implementation mode, searching elements of the page to be tested for a first related element comprising the text to be tested; and screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as the target elements.
For example, when an element is found in each attribute or title that includes text to be tested, elements that are not visible may be filtered, leaving visible elements as target elements.
In one possible implementation, it may be determined whether text content exists in elements of the page to be tested, where the text content includes the elements of the text to be tested; if the text content in the elements of the page to be tested comprises the elements of the text to be tested, taking the elements as the first related elements; if the text content does not exist in the elements of the page to be tested and the elements of the text to be tested, determining that the elements of the page to be tested, of which the attribute values comprise the elements of the text to be tested, are the first related elements.
That is, when the first relevant element is searched based on the text to be tested, an element corresponding to the text to be tested and the text content (for example, attribute such as title, text, etc.) can be searched preferentially, and when there is no element corresponding to the text to be tested and the text content, an element corresponding to the text to be tested and the content of an auxiliary attribute such as a variable attribute or a remark class (for example, attribute such as placeholder, value, etc.) can be searched. If the element corresponding to the text to be tested is not found in the attached attribute, search timeout information can be generated to remind the user to check whether the input text to be tested is correct.
In a possible implementation manner, the operation to be tested comprises the step of determining an element positioned at the operation position of the first visible element as a second related element based on the operation position of the text to be tested; and screening out invisible elements in the second related elements, and taking visible elements in the second related elements as the target elements.
That is to say, after determining the element corresponding to the text to be tested, the element that should be actually operated may be determined according to the operation orientation in the operation to be tested, for example, in fig. 2, if the test content represents that the first input box b is clicked, the text to be tested may be "closest", and after the element corresponding to the text to be tested is obtained as the first drop-down box a through searching and filtering, the target element that should be actually operated may be determined as the first input box b on the right side of the first drop-down box a based on the operation "click right side" to be tested.
In a possible implementation manner, when the operation to be tested includes the operation direction, the actual operation position may be a position where the element corresponding to the text to be operated is away from the preset length, and the operation direction may further include a length specified by the user, and then the actual operation position is a position where the element corresponding to the text to be operated is away from the specified length.
Considering that a plurality of elements may remain after the screening filtering is performed, when there is more than one visible element to be determined as the target element, the relevance of the text of each visible element to the text to be tested may be determined, and the visible element with the highest relevance may be determined as the target element.
For example, when the text to be tested is "save", and there are three visible elements to be determined as target elements, namely "save", "save picture", and "save current website", the relevancy between each visible element and the text to be tested may be calculated, where the relevancy may be a ratio of the text length of the text to be tested to the text length of the visible element to be tested, and for example, the relevancy between the text content or the visible element with attribute content "save" and the text to be tested is 100%, the relevancy between the text content or the visible element with attribute content "save picture" and the text to be tested is 50%, and the relevancy between the text content or the visible element with attribute content "save current website" and the text to be tested is about 33%, then the final target element may be determined as the text content or the visible element with attribute content "save".
In one possible embodiment, the invisible elements are screened out by at least one of:
elements that are not user-manipulated are screened out as invisible elements, e.g., elements of a script tag or style tag are typically elements that do not belong to a user manipulation and typically have no visible text presentation, and thus such elements can be screened out.
The element with the attribute including the hidden attribute is screened out as an invisible element, the attribute may be an attribute of the element itself or an attribute of an ancestor of the element (e.g., a parent element of the parent element, etc.), for example, when an element or its parent element has an attribute of aria-hidden ═ true, it indicates that the attribute is invisible to the user, and the screening out may be performed, or when a style attribute of an element or its parent element includes a description of display: none, it indicates that the attribute is invisible to the user, and the screening out may be performed.
An element with a width or height of 0 in the space size is screened out as an invisible element, for example, when the width or height attribute in the space size of an element is 0, the element cannot be effectively displayed in a webpage, and is invisible to a user, so that the element can be screened out.
And S13, generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested.
After the target element is determined, a test instruction for characterizing that an operation consistent with the type of the operation to be tested is performed on the target element may be generated, for example, when the operation to be tested is a click type (including click, click left side, click right side), the test instruction for clicking the target element may be generated, and when the operation to be tested is an input text, the corresponding text content may be input into the input box of the target element.
It should be noted that, in the case of acquiring a plurality of contents to be tested, a plurality of operations to be tested corresponding to each of the contents to be tested may be generated, and in this case, in order to ensure the response speed of the computer, a pause time may be added after each of the operations to be tested, so as to avoid the problem that the computer cannot respond because the plurality of operations are performed without a pause.
And S14, testing the page based on the test instruction.
After the test instruction is executed, a test result corresponding to the test instruction can be obtained, whether the test result is consistent with the expected result or not is judged, and whether the page meets the test purpose or not can be determined.
In one possible implementation, an expected result may be obtained, the test instruction executed, and an execution result determined, whether the execution result is consistent with the expected result.
The expected result may be an expected result for one test instruction or may be an expected result for a plurality of consecutive test instructions. For example, if the expected result for the 1 st to 5 th test instructions is "jump to target page", and if the expected result for the 6 th to 20 th test instructions is "jump to pay page", then the test fails if the jump to target page is not performed after the 5 th test instruction is completed, or the test fails if the jump to pay page is not performed after the test instruction is performed to 20 th.
Fig. 3 is a schematic diagram of a process of finding elements according to an exemplary disclosed embodiment, as shown in fig. 3, after obtaining, for example, "ui click arbitrary event" (i.e., click text content "arbitrary event"), "ui click last >" (i.e., click last text content ">"), and "ui sent text hello" (i.e., input text "hello") to wait for test content, using Selenium to inject a jQuery object into a browser through WebDriver, and in a page to be tested opened in a Selenium-opened browser, finding elements each containing "arbitrary event" in the page to be tested through jQuery, and screening the elements to obtain a final target element corresponding to "ui click arbitrary event", and continuing the above process to find a target element corresponding to other content to be tested. After each target element is found, the text is converted into the element where the text is located, the element is returned to the selenium, and the selenium is called to operate the element.
Based on the technical scheme, the following technical effects can be at least achieved:
the target elements in the page are automatically positioned according to the text contents displayed in the page to be tested, so that the corresponding test instructions can be generated through the text to be tested and the operation to be tested, the steps that a user manually inputs codes of the target elements or manually queries the target elements through an xpath language are reduced, the generation mode of the page test instructions is simplified, and the page test efficiency can be improved.
FIG. 4 is a block diagram illustrating a page test apparatus according to an exemplary disclosed embodiment, the apparatus 400 including, as shown in FIG. 4:
the obtaining module 410 is configured to obtain at least one piece of content to be tested, where each piece of content to be tested includes a text to be tested and an operation to be tested, and the text to be tested is text content displayed in a page to be tested.
A determining module 420, configured to determine a target element corresponding to the text to be tested from elements included in the page to be tested.
A generating module 430, configured to generate a test instruction corresponding to the content to be tested based on the target element and the operation to be tested.
The testing module 440 is configured to test the page based on the testing instruction.
In a possible implementation manner, the determining module 420 is configured to find a first relevant element including the text to be tested among elements of the page to be tested, screen out invisible elements in the first relevant element, and use a first visible element in the first relevant element as the target element.
In a possible embodiment, the operation to be tested includes an operation orientation based on the text to be tested, and the determining module 420 is further configured to determine that an element located in the operation orientation of the first visible element is a second related element, screen out invisible elements in the second related element, and use visible elements in the second related element as the target element.
In a possible implementation manner, the apparatus further includes a correlation module, configured to determine, when there is more than one visible element to be determined as a target element, a correlation degree between a text of each visible element and the text to be tested, and determine a visible element with a highest correlation degree as the target element.
In a possible embodiment, the determination module is configured to screen out the invisible elements by: screening out elements which are not operated by a user as invisible elements; screening out elements with the attributes including hidden attributes as invisible elements; elements with a width or height of 0 of the spatial dimension are screened out as invisible elements.
In a possible implementation manner, the determining module is further configured to determine whether a text content includes an element of the text to be tested in the elements of the page to be tested, if the text content includes the element of the text to be tested, the element is taken as the first relevant element, and if the text content does not include the element of the text to be tested in the elements of the page to be tested, it is determined that an attribute value in the element of the page to be tested includes the element of the text to be tested as the first relevant element.
In a possible implementation manner, the obtaining module is further configured to obtain an expected result, and the testing module is configured to execute the test instruction, determine an execution result, and determine whether the execution result is consistent with the expected result.
Based on the technical scheme, the following technical effects can be at least achieved:
the target elements in the page are automatically positioned according to the text content displayed in the page to be tested, so that the corresponding test instruction can be generated through the text to be tested and the operation to be tested, the steps that a user carries out element positioning based on the element characteristics of the target page or positions the target elements through complex grammars such as CSS, XPath and the like are reduced, the generation mode of the page test instruction is simplified, and the page test efficiency can be improved.
Referring now to FIG. 5, a block diagram of an electronic device 500 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, electronic device 500 may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 500 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 501.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. 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.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the name of a module in some cases does not constitute a limitation on the module itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides, in accordance with one or more embodiments of the present disclosure, a page testing method, the method comprising: obtaining at least one piece of content to be tested, wherein each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested; determining a target element corresponding to the text to be tested from elements contained in the page to be tested; generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested; and testing the page based on the test instruction.
Example 2 provides the method of example 1, the determining a target element corresponding to the text to be tested from elements included in the page to be tested, including: searching a first related element comprising the text to be tested in the elements of the page to be tested; and screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as the target elements.
Example 3 provides the method of example 2, further comprising, in accordance with one or more embodiments of the present disclosure: determining an element located at the operational orientation of the first visible element as a second related element; and screening out invisible elements in the second related elements, and taking visible elements in the second related elements as the target elements.
Example 4 provides the method of example 2 or 3, further comprising, in accordance with one or more embodiments of the present disclosure: when more than one visible element to be determined as the target element exists, determining the relevancy between the text of each visible element and the text to be tested; and determining the visible element with the highest correlation degree as the target element.
Example 5 provides the method of example 2 or 3, the invisible element being screened out by at least one of: screening out elements which are not operated by a user as invisible elements; screening out elements with the attributes including hidden attributes as invisible elements; elements with a width or height of 0 of the spatial dimension are screened out as invisible elements.
Example 6 provides the method of example 2, the finding a first relevant element including the text to be tested among elements of the page to be tested, including: determining whether text content exists in the elements of the page to be tested and whether the text content comprises the elements of the text to be tested; if the text content in the elements of the page to be tested comprises the elements of the text to be tested, taking the elements as the first related elements; if the text content does not exist in the elements of the page to be tested and the elements of the text to be tested, determining that the elements of the page to be tested, of which the attribute values comprise the elements of the text to be tested, are the first related elements.
Example 7 provides the method of example 1, further comprising, in accordance with one or more embodiments of the present disclosure: obtaining an expected result; the testing the page based on the test instruction comprises: executing the test instruction and determining an execution result; determining whether the execution result is consistent with the expected result.
Example 8 provides, in accordance with one or more embodiments of the present disclosure, a page testing apparatus, the apparatus comprising: the system comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring at least one piece of content to be tested, each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested; the determining module is used for determining a target element corresponding to the text to be tested from elements contained in the page to be tested; the generating module is used for generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested; and the testing module is used for testing the page based on the testing instruction.
Example 9 provides the apparatus of example 8, the determining module is to find a first relevant element including the text to be tested among elements of the page to be tested, screen out an invisible element among the first relevant elements, and take a first visible element among the first relevant elements as the target element.
Example 10 provides the apparatus of example 9, the operation to be tested including an operation orientation based on the text to be tested, the determination module further configured to determine an element located in the operation orientation of the first visible element as a second related element, screen out invisible elements of the second related element, and take visible elements of the second related element as the target element.
Example 11 provides the apparatus of example 9 or 10, further including a correlation module to determine a degree of correlation of a text of each visible element with the text to be tested when there is more than one visible element to be determined as a target element, and determine a visible element with a highest degree of correlation as the target element.
Example 12 provides the apparatus of example 9 or 10, the determination module to screen out the invisible elements by: screening out elements which are not operated by a user as invisible elements; screening out elements with the attributes including hidden attributes as invisible elements; elements with a width or height of 0 of the spatial dimension are screened out as invisible elements.
According to one or more embodiments of the present disclosure, example 13 provides the apparatus of example 9, where the determining module is further configured to determine whether there is an element of the text content that includes the text to be tested in the elements of the page to be tested, if there is an element of the text content that includes the text to be tested in the elements of the page to be tested, the element is taken as the first relevant element, and if there is no element of the text content that includes the text to be tested in the elements of the page to be tested, it is determined that an element of the elements of the page to be tested whose attribute values include the text to be tested is the first relevant element.
Example 14 provides the apparatus of example 8, the obtaining module further to obtain an expected result, and the testing module to execute the test instruction, determine an execution result, and determine whether the execution result is consistent with the expected result.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims (10)
1. A page testing method is characterized by comprising the following steps:
obtaining at least one piece of content to be tested, wherein each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested;
determining a target element corresponding to the text to be tested from elements contained in the page to be tested;
generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested;
and testing the page based on the test instruction.
2. The method of claim 1, wherein the determining a target element corresponding to the text to be tested from the elements contained in the page to be tested comprises:
searching a first related element comprising the text to be tested in the elements of the page to be tested;
and screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as the target elements.
3. The method of claim 2, wherein the operation to be tested comprises an operation orientation based on the text to be tested, the method further comprising:
determining an element located at the operational orientation of the first visible element as a second related element;
and screening out invisible elements in the second related elements, and taking visible elements in the second related elements as the target elements.
4. The method according to any one of claims 2 or 3, further comprising:
when more than one visible element to be determined as the target element exists, determining the relevancy between the text of each visible element and the text to be tested;
and determining the visible element with the highest correlation degree as the target element.
5. The method according to any one of claims 2 or 3, wherein the invisible elements are screened out by at least one of:
screening out elements which are not operated by a user as invisible elements;
screening out elements with the attributes including hidden attributes as invisible elements;
elements with a width or height of 0 of the spatial dimension are screened out as invisible elements.
6. The method of claim 2, wherein the searching for the first related element including the text to be tested in the elements of the page to be tested comprises:
determining whether text content exists in the elements of the page to be tested and whether the text content comprises the elements of the text to be tested;
if the text content in the elements of the page to be tested comprises the elements of the text to be tested, taking the elements as the first related elements;
if the text content does not exist in the elements of the page to be tested and the elements of the text to be tested, determining that the elements of the page to be tested, of which the attribute values comprise the elements of the text to be tested, are the first related elements.
7. The method of claim 1, further comprising: obtaining an expected result;
the testing the page based on the test instruction comprises:
executing the test instruction and determining an execution result;
determining whether the execution result is consistent with the expected result.
8. A page testing apparatus, characterized in that the apparatus comprises:
the system comprises an acquisition module, a display module and a display module, wherein the acquisition module is used for acquiring at least one piece of content to be tested, each piece of content to be tested comprises a text to be tested and an operation to be tested, and the text to be tested is character content displayed in a page to be tested;
the determining module is used for determining a target element corresponding to the text to be tested from elements contained in the page to be tested;
the generating module is used for generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested;
and the testing module is used for testing the page based on the testing instruction.
9. A computer-readable medium, on which a computer program is stored, characterized in that the program, when being executed by processing means, carries out the steps of the method of any one of claims 1 to 7.
10. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110513586.1A CN113094286B (en) | 2021-05-11 | 2021-05-11 | Page test method and device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110513586.1A CN113094286B (en) | 2021-05-11 | 2021-05-11 | Page test method and device, storage medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113094286A true CN113094286A (en) | 2021-07-09 |
CN113094286B CN113094286B (en) | 2024-05-10 |
Family
ID=76665111
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110513586.1A Active CN113094286B (en) | 2021-05-11 | 2021-05-11 | Page test method and device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113094286B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113849416A (en) * | 2021-10-29 | 2021-12-28 | 北京字节跳动网络技术有限公司 | Test method, test device, storage medium and electronic equipment |
CN114490395A (en) * | 2022-01-27 | 2022-05-13 | 北京飞书科技有限公司 | Test processing method, device, equipment and medium |
WO2024174704A1 (en) * | 2023-02-24 | 2024-08-29 | 天翼云科技有限公司 | Element positioning method and apparatus, and electronic device and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103034583A (en) * | 2011-09-30 | 2013-04-10 | 国际商业机器公司 | Method and system for processing automatic test scrip of software |
US20140250426A1 (en) * | 2011-11-18 | 2014-09-04 | Huawei Technologies Co., Ltd. | Page testing method and page testing apparatus |
US20140359371A1 (en) * | 2013-06-03 | 2014-12-04 | Sap Ag | Determining behavior models |
CN109800161A (en) * | 2018-12-28 | 2019-05-24 | 网宿科技股份有限公司 | A kind of components testing method of user interface, electronic equipment and can storage medium |
CN112015635A (en) * | 2019-05-31 | 2020-12-01 | 北京京东尚科信息技术有限公司 | Page testing method, page testing device, electronic equipment and storage medium |
CN112231214A (en) * | 2020-10-16 | 2021-01-15 | 百度国际科技(深圳)有限公司 | Page testing method and device, electronic equipment and medium |
-
2021
- 2021-05-11 CN CN202110513586.1A patent/CN113094286B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103034583A (en) * | 2011-09-30 | 2013-04-10 | 国际商业机器公司 | Method and system for processing automatic test scrip of software |
US20140250426A1 (en) * | 2011-11-18 | 2014-09-04 | Huawei Technologies Co., Ltd. | Page testing method and page testing apparatus |
US20140359371A1 (en) * | 2013-06-03 | 2014-12-04 | Sap Ag | Determining behavior models |
CN109800161A (en) * | 2018-12-28 | 2019-05-24 | 网宿科技股份有限公司 | A kind of components testing method of user interface, electronic equipment and can storage medium |
CN112015635A (en) * | 2019-05-31 | 2020-12-01 | 北京京东尚科信息技术有限公司 | Page testing method, page testing device, electronic equipment and storage medium |
CN112231214A (en) * | 2020-10-16 | 2021-01-15 | 百度国际科技(深圳)有限公司 | Page testing method and device, electronic equipment and medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113849416A (en) * | 2021-10-29 | 2021-12-28 | 北京字节跳动网络技术有限公司 | Test method, test device, storage medium and electronic equipment |
CN114490395A (en) * | 2022-01-27 | 2022-05-13 | 北京飞书科技有限公司 | Test processing method, device, equipment and medium |
WO2024174704A1 (en) * | 2023-02-24 | 2024-08-29 | 天翼云科技有限公司 | Element positioning method and apparatus, and electronic device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113094286B (en) | 2024-05-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113094286B (en) | Page test method and device, storage medium and electronic equipment | |
CN112528595B (en) | Document processing method and device and electronic equipment | |
CN107679113B (en) | Light application acquisition method and device and electronic device | |
CN112035092A (en) | Form processing method, device, equipment and readable medium | |
CN112433730B (en) | Code detection rule generation method and device and electronic equipment | |
CN111753064A (en) | Man-machine interaction method and device | |
CN110968314B (en) | Page generation method and device | |
CN118502857A (en) | Interactive processing method, device, equipment, medium and program product of user interface | |
CN115017110A (en) | Information processing method, device, terminal and storage medium | |
CN110717126A (en) | Page browsing method and device, electronic equipment and computer readable storage medium | |
CN111723309A (en) | Method and device for searching web page | |
CN115756452A (en) | Target page code generation method, device, storage medium and program product | |
US20230409813A1 (en) | Document processing method, apparatus and device, and medium | |
CN112380476A (en) | Information display method and device and electronic equipment | |
CN110069186B (en) | Method and equipment for displaying operation interface of application | |
KR20210084641A (en) | Method and apparatus for transmitting information | |
CN109992698B (en) | Data processing method and device, electronic equipment and readable storage medium | |
CN116755665A (en) | General page template development method and system based on database table structure | |
CN113448820A (en) | Webpage testing method and device | |
CN113221572B (en) | Information processing method, device, equipment and medium | |
CN112307723B (en) | Method and device for generating code document and electronic equipment | |
CN114626332A (en) | Content display method and device and electronic equipment | |
US20220342955A1 (en) | Information processing apparatus, information processing method, and program | |
CN111414106A (en) | Title display method and device, electronic equipment and computer readable medium | |
CN110096392B (en) | Method and device for outputting information |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |