CN113094286B - Page test method and device, storage medium and electronic equipment - Google Patents

Page test method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN113094286B
CN113094286B CN202110513586.1A CN202110513586A CN113094286B CN 113094286 B CN113094286 B CN 113094286B CN 202110513586 A CN202110513586 A CN 202110513586A CN 113094286 B CN113094286 B CN 113094286B
Authority
CN
China
Prior art keywords
tested
text
elements
page
visible
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.)
Active
Application number
CN202110513586.1A
Other languages
Chinese (zh)
Other versions
CN113094286A (en
Inventor
胡雷庭
李珊
陶健
陆发权
李育国
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202110513586.1A priority Critical patent/CN113094286B/en
Publication of CN113094286A publication Critical patent/CN113094286A/en
Application granted granted Critical
Publication of CN113094286B publication Critical patent/CN113094286B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

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)
  • Machine Translation (AREA)
  • Debugging And Monitoring (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: acquiring 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 a text 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 test method and device can improve page test efficiency.

Description

Page test method and device, storage medium and electronic equipment
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a page testing method and device, a storage medium and electronic equipment.
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 lands. Currently, automated testing of pages can be performed by Selenium tools, but the user needs to actively locate the page element to be manipulated first, which can typically be done by the numerous element locating methods provided by Selenium. On the one hand, the user needs to know the details of the operated page element, such as id, name, class, tag attributes thereof, and apply a correct method to position the element, and for some elements with little positioning information, complicated grammar such as CSS selector or XPath has to be adopted to position, which raises the threshold of the test case for writing, and reduces the stability of the test case, and small changes of the page element can cause the execution failure of the case, on the other hand, the automatic case writing style of the positioning element and the operation element is firstly performed, so that the business logic needing to be covered in the test case becomes separated and broken, and is not intuitive any more.
At present, no method capable of more intuitively and rapidly performing browser automation page test exists.
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, the method comprising: acquiring 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 a text 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 acquisition module is used for acquiring 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 text content displayed in a page to be tested; the determining module is used for determining target elements corresponding to the text to be tested from elements contained in the page to be tested; the generation 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 test module is used for testing the page based on the test 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 device 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 and a processing device, where the storage device stores a computer program, and the processing device is 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, at least the following technical effects can be achieved:
The method and the device have the advantages that the target elements in the page are automatically positioned according to the text content displayed in the page to be tested, so that corresponding test instructions can be generated through the text to be tested and the operation to be tested, the steps that a user positions the elements based on the characteristics of the target page elements or positions the target elements through CSS, XPath and other complex grammars are reduced, the generation mode of the page test instructions is simplified, and the page test efficiency can be improved.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flow chart illustrating a page test method according to an exemplary disclosed embodiment
FIG. 2 is a schematic diagram of a page to be tested, according to an exemplary disclosed embodiment.
FIG. 3 is a schematic diagram illustrating a process of finding an element according to an exemplary disclosed embodiment.
FIG. 4 is a block diagram illustrating a page testing apparatus according to an exemplary disclosed embodiment.
Fig. 5 is a block diagram of 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 have been shown in the accompanying 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 are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present 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. Furthermore, 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 "including" and variations thereof as used herein are intended to be 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. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
FIG. 1 is a flow chart of a page testing method according to an exemplary disclosed embodiment, which may be applied to a code library, an application program or a web page, or an electronic device, as shown in FIG. 1, and the method includes the following steps:
S11, acquiring 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 text content displayed in a page to be tested.
A piece of content to be tested may generate a test instruction, which may characterize performing a certain operation 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 frame, the text content displayed in a is "nearest", b is a first input frame, b does not display the text content, c is a first display frame, the display frame cannot be clicked and selected or modified by a user, and belongs to an inoperable element, and the first display frame may also be implemented based on the dependency of the first input frame, and is not an independent element. In addition, d is a second drop-down frame, the text content displayed in d is "any event is made", e is a third drop-down frame, the text content displayed in e is "total times", f is a fourth drop-down frame, the text content displayed in f is ">", g is a second input frame, and the text content displayed in g is "0".
In the conventional web page testing manner, if the fourth drop-down frame needs to be clicked, the user needs to find the code of the element corresponding to the fourth drop-down frame, for example, the element corresponding to the fourth drop-down frame may be located through the following code: elem = driver =find_element_by_css_selector (' div [ title = ">" ]), it is worth noting that the elements have different types, the different types correspond to different code types, the types are various and difficult to memorize, and the query codes are implemented based on CSS grammar, so the web page test mode needs a higher use threshold.
In the disclosure, based on the web page, if the content to be tested is clicking the fourth drop-down box, the text to be tested may be ">", the operation to be tested may be "clicking", and the code corresponding to the test content may be "ui click >". If the test content is clicking the first input box and the first input box has no corresponding text content, the first input box may be positioned by surrounding text content and be positioned and adjusted by the operation to be tested, for example, the text to be tested may be "nearest", the operation to be tested may be "clicking right", the code corresponding to the test content may be "ui CLICK RIGHT of nearest", or the text to be tested may be "day", the operation to be tested may be "clicking left", 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 is originally required 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 User is more visual.
In consideration of the functional test of the page, a plurality of operations are generally required to be performed on a plurality of elements, so that more than one piece of content to be tested can be obtained, and each piece of content to be tested is sequentially processed to obtain a plurality of test instructions. For example, in the case where the test requirement is 7 inputted in the first input box and 20 inputted in the second input box, the corresponding test contents may be "ui CLICK RIGHT of recently", "ui send text 7", "ui click 0", "ui send text 20" in this order.
In one possible implementation manner, when the operation to be tested includes an operation direction, the actual operation position may be a position of an element corresponding to the text to be operated from a preset length, and the operation direction may further include a length specified by the user, and then the actual operation position is a position of an element corresponding to the text to be operated from the specified length.
It should be noted that, the text content in the web page may be repeated, so that the text to be tested may further include numbers of the text, for example, there are 4 "open" in the web page, 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. default position), the text to be tested refers to the element in which the 1 st text content in the web page is "open", 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)", and the text to be tested refers to the element in which the 2 nd text content in the web page is "open".
S12, determining target elements corresponding to the text to be tested from elements contained in the page to be tested.
The 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 specific information can be navigated through the DOM. In the present disclosure, the search for elements may be implemented by injecting jQuery into the page to be tested through Selenium.
In consideration of the possibility of finding a plurality of elements based on the text to be tested, after finding a plurality of elements, each found element may also be screened to obtain more accurate elements.
In a possible implementation manner, searching for a first related element comprising the text to be tested from elements of the page to be tested; 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 elements of text to be tested are found in each attribute or title, elements that are not visible therein may be filtered, leaving visible elements as target elements.
In one possible implementation manner, it may be determined whether text content including the element of the text to be tested exists in the element of the page to be tested; if the text content in the element of the page to be tested comprises the element of the text to be tested, taking the element as the first related element; if the text content does not exist in the element of the page to be tested and comprises the element of the text to be tested, determining that the element of the page to be tested, the attribute value of which comprises the element of the text to be tested, is the first related element.
That is, when searching for the first related element based on the text to be tested, the element whose text content (for example, attribute such as title, text, etc.) corresponds to the text to be tested may be searched for preferentially, and when there is no element whose text content corresponds to the text to be tested, the element whose content of an auxiliary attribute (for example, attribute such as placeholder, value, etc.) such as variable attribute or remark class corresponds to the text to be tested may be searched for. If no element corresponding to the text to be tested is found in the accessory attribute, search timeout information can be generated to remind the user to check whether the input text to be tested is correct.
In one possible implementation manner, the operation to be tested includes determining, based on an operation position of the text to be tested, an element located in the operation position of the first visible element as a second related element; screening out invisible elements in the second related elements, and taking the visible elements in the second related elements as the target elements.
That is, 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 direction 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 "nearest", after retrieving and filtering to obtain the element corresponding to the text to be tested as the first drop-down box a, the target element that should be actually operated may be determined to be the first input box b on the right side of the first drop-down box a based on the operation to be tested "clicking on the right side".
In one possible implementation manner, when the operation to be tested includes an operation direction, the actual operation position may be a position of an element corresponding to the text to be operated from a preset length, and the operation direction may further include a length specified by the user, and then the actual operation position is a position of an element corresponding to the text to be operated from the specified length.
Considering that a plurality of elements may remain after the screening filtration is performed, when more than one visible element is to be determined as a target element, the relevance between the text of each visible element and 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 "saved" and there are three visible elements to be determined as target elements, which are respectively "saved", "saved picture", and "saved current website", the correlation between each visible element and the text to be tested may be calculated, where the correlation may be a ratio of text lengths of the text to be tested and the visible element, for example, the correlation between the visible element whose text content or attribute content is "saved" and the text to be tested is 100%, the correlation between the visible element whose text content or attribute content is "saved picture" and the text to be tested is 50%, and the correlation between the visible element whose text content or attribute content is "saved current website" and the text to be tested is about 33%, then it may be determined that the final target element is the visible element whose text content or attribute content is "saved".
In one possible embodiment, the invisible element is screened out by at least one of:
Elements that are not user-operated 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 operation and are typically not visible literal presentations, so such elements can be screened out.
An element whose attribute includes a hidden attribute is screened out as an invisible element, which may be an attribute of the element itself or an attribute of an ancestor of the element (e.g., a parent element of a parent element, etc.), for example, when an element or its parent element has an attribute of aria-hidden=true, this attribute is not visible to the user, and screening out may be performed, or when an element or its parent element's style attribute includes a description of display: none, this attribute is not visible to the user, and screening out may be performed.
Elements with a width or height of 0 in the spatial dimension are screened out as invisible elements, for example, when the width or heigh attribute in the spatial dimension of one element is 0, the element cannot be effectively displayed in the webpage, is invisible to the user, and can be screened out.
S13, generating a test instruction corresponding to the content to be tested based on the target element and the operation to be tested.
After determining the target element, a test instruction representing an operation consistent with the operation type to be tested on the target element can be generated, for example, when the operation to be tested is a click type (including clicking, clicking left side and clicking right side), the test instruction for clicking the target element can be generated, and when the operation to be tested is an input text, the corresponding text content can be input into an input box of the target element.
It should be noted that, when a plurality of pieces of content to be tested are obtained, a plurality of pieces of operations to be tested corresponding to each piece of content to be tested may be generated, in this case, in order to ensure the response speed of the computer, a dwell time may be added after each piece of operations to be tested, so as to avoid the problem that the computer cannot respond due to the fact that the plurality of pieces of operations are performed without dwell.
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 is judged, and whether the page meets the test purpose can be determined.
In one possible implementation, an expected result may be obtained, the test instruction is executed, and an execution result is determined, and whether the execution result is consistent with the expected result is determined.
The expected result may be an expected result for one test instruction or an expected result for a plurality of consecutive test instructions. For example, when the expected result for the 1 st to 5 th test instructions is "jump to the target page", when the expected result for the 6 th to 20 th test instructions is "jump to the payment page", no jump to the target page after the 5 th test instruction is executed represents a test failure, or no jump to the payment page after the 20 th test instruction is executed represents a test failure.
FIG. 3 is a schematic diagram illustrating a process for searching elements according to an exemplary disclosed embodiment, as shown in FIG. 3, after obtaining, for example, "ui click arbitrary event" (i.e., clicking text content "arbitrary event"), "ui CLICK LAST >" (i.e., clicking last text content ">"), and "ui send text hello" (i.e., inputting text "hello") waiting for test content, using Selenium to inject jQuery objects into a browser through WebDriver, and searching for elements containing "arbitrary event" in the to-be-tested page through jQuery in the to-be-tested page opened in the browser opened in Selenium, and screening the elements to obtain final target elements corresponding to "ui click arbitrary event", and continuing the above process to find target elements corresponding to other to-be-tested content. After each target element is found, converting the text into the element where the text is located, returning the element to the selenium, and calling the selenium to operate on the element.
Based on the technical scheme, at least the following technical effects can be achieved:
The method and the device have the advantages that the target elements in the page are automatically positioned according to the text content displayed in the page to be tested, so that 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 xpath languages 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 of a page testing apparatus, as shown in FIG. 4, according to an exemplary disclosed embodiment, the apparatus 400 includes:
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 a text content displayed in a page to be tested.
And the determining module 420 is configured to determine a target element corresponding to the text to be tested from elements included in the page to be tested.
The generating module 430 is configured to generate a test instruction corresponding to the content to be tested based on the target element and the operation to be tested.
And the test module 440 is configured to test the page based on the test instruction.
In a possible implementation manner, the determining module 420 is configured to search elements of the page to be tested for a first relevant element including the text to be tested, screen out an invisible element in the first relevant element, and take the first visible element in the first relevant element as the target element.
In a possible implementation manner, the operation to be tested includes determining, based on an operation position of the text to be tested, that an element located in the operation position of the first visible element is a second related element, screening out invisible elements in the second related element, and taking visible elements in the second related element as the target element.
In a possible implementation manner, the device further comprises a correlation module, which is used for determining the correlation degree of the text of each visible element and the text to be tested when more than one visible element is to be determined as the target element, and determining the visible element with the highest correlation degree as the target element.
In one possible implementation, the determining module is configured to screen out the invisible element by: screening out elements which are not operated by a user as invisible elements; screening out elements whose attributes include hidden attributes as invisible elements; elements of space size with width or height 0 are screened out as invisible elements.
In a possible implementation manner, the determining module is further configured to determine whether text content in an element of the to-be-tested page includes the element of the to-be-tested text, if the text content in the element of the to-be-tested page includes the element of the to-be-tested text, take the element as the first relevant element, and if the text content in the element of the to-be-tested page does not include the element of the to-be-tested text, determine that an attribute value in the element of the to-be-tested page includes the element of the to-be-tested text is the first relevant element.
In a possible implementation manner, the acquiring module is further configured to acquire an expected result, and the testing module is configured to execute the test instruction and determine an execution result, and determine whether the execution result is consistent with the expected result.
Based on the technical scheme, at least the following technical effects can be achieved:
The method and the device have the advantages that the target elements in the page are automatically positioned according to the text content displayed in the page to be tested, so that corresponding test instructions can be generated through the text to be tested and the operation to be tested, the steps that a user positions the elements based on the characteristics of the target page elements or positions the target elements through CSS, XPath and other complex grammars are reduced, the generation mode of the page test instructions is simplified, and the page test efficiency can be improved.
Referring now to fig. 5, a schematic diagram of an electronic device 500 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device 500 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 501, which may perform various appropriate actions and processes according to 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 required 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 via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
In general, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 507 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 508 including, for example, magnetic tape, hard disk, etc.; and communication means 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 shows an electronic device 500 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or from the storage means 508, or from the ROM 502. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 501.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any 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 context of this 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 in software or hardware. The name of a module does not in some cases define the module itself.
The functions described above herein 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: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), 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. The 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.
In accordance with one or more embodiments of the present disclosure, example 1 provides a page testing method, the method comprising: acquiring 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 a text 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.
According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, where determining, from elements included in the page to be tested, a target element corresponding to the text to be tested includes: searching a first related element comprising the text to be tested in the elements of the page to be tested; screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as the target elements.
In accordance with one or more embodiments of the present disclosure, example 3 provides the method of example 2, the method further comprising: determining an element located at the operational orientation of the first visual element as a second related element; screening out invisible elements in the second related elements, and taking the visible elements in the second related elements as the target elements.
In accordance with one or more embodiments of the present disclosure, example 4 provides the method of example 2 or 3, the method further comprising: when more than one visible element is to be determined as a target element, determining the relativity 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, according to one or more embodiments of the present disclosure, the invisible element is screened out by at least one of: screening out elements which are not operated by a user as invisible elements; screening out elements whose attributes include hidden attributes as invisible elements; elements of space size with width or height 0 are screened out as invisible elements.
According to one or more embodiments of the present disclosure, example 6 provides the method of example 2, wherein searching the element of the page to be tested for the first related element including the text to be tested includes: determining whether text content in the elements of the page to be tested comprises the elements of the text to be tested; if the text content in the element of the page to be tested comprises the element of the text to be tested, taking the element as the first related element; if the text content does not exist in the element of the page to be tested and comprises the element of the text to be tested, determining that the element of the page to be tested, the attribute value of which comprises the element of the text to be tested, is the first related element.
Example 7 provides the method of example 1, according to one or more embodiments of the present disclosure, the method further comprising: obtaining an expected result; the step of testing the page based on the test instruction comprises the following steps: executing the test instruction and determining an execution result; determining whether the execution result is consistent with the expected result.
Example 8 provides a page testing apparatus according to one or more embodiments of the present disclosure, the apparatus comprising: the acquisition module is used for acquiring 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 text content displayed in a page to be tested; the determining module is used for determining target elements corresponding to the text to be tested from elements contained in the page to be tested; the generation 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 test module is used for testing the page based on the test instruction.
According to one or more embodiments of the present disclosure, example 9 provides the apparatus of example 8, wherein the determining module is configured to find a first relevant element including the text to be tested in the element of the page to be tested, screen out an invisible element in the first relevant element, and take the first visible element in the first relevant element as the target element.
According to one or more embodiments of the present disclosure, example 10 provides the apparatus of example 9, the operation to be tested includes determining, based on an operation orientation of the text to be tested, an element located in the operation orientation of the first visible element to be a second related element, screening out invisible elements in the second related element, and taking visible elements in the second related element as the target element.
According to one or more embodiments of the present disclosure, example 11 provides the apparatus of example 9 or 10, further comprising a correlation module configured to determine, when there is more than one visible element to be determined as a target element, a degree of correlation between a text of each visible element and the text to be tested, and determine a visible element with the highest degree of correlation as the target element.
According to one or more embodiments of the present disclosure, example 12 provides the apparatus of example 9 or 10, the determining module to screen out the invisible element by: screening out elements which are not operated by a user as invisible elements; screening out elements whose attributes include hidden attributes as invisible elements; elements of space size with width or height 0 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 text content in an element of the page to be tested includes the element of the text to be tested, if text content in the element of the page to be tested includes the element of the text to be tested, take the element as the first relevant element, and if text content in an element of the page to be tested does not include the element of the text to be tested, determine that an attribute value in an element of the page to be tested includes the element of the text to be tested is the first relevant element.
In accordance with one or more embodiments of the present disclosure, example 14 provides the apparatus of example 8, the obtaining module further to obtain an expected result, the testing module to execute the test instruction and determine an execution result, and determine whether the execution result is consistent with the expected result.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although 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. In 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 limiting the scope of the present 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 example forms of implementing the claims. The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.

Claims (9)

1. A method of testing a page, the method comprising:
acquiring 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 a text 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;
based on the test instruction, testing the page;
The determining a target element corresponding to the text to be tested from elements contained in the page to be tested comprises the following steps:
Searching a first related element comprising the text to be tested in the elements of the page to be tested;
screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as visible elements to be determined as target elements;
When more than one visible element is to be determined as a target element, taking the visible element with the highest correlation degree with the text to be tested as the target element, wherein the correlation degree is used for representing the ratio of the text lengths of the text to be tested and the visible element;
when the visible element to be determined as the target element is equal to one, the visible element is taken as the target element.
2. The method of claim 1, 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 visual element as a second related element;
Screening out invisible elements in the second related elements, and taking the visible elements in the second related elements as the target elements.
3. The method according to any one of claims 1 or 2, further comprising:
and determining the correlation degree of the text of each visible element and the text to be tested as the correlation degree of each visible element and the text to be tested.
4. The method according to any one of claims 1 or 2, wherein the invisible element is screened out by at least one of:
screening out elements which are not operated by a user as invisible elements;
screening out elements whose attributes include hidden attributes as invisible elements;
elements of space size with width or height 0 are screened out as invisible elements.
5. The method of claim 1, wherein the searching for the first related element including the text to be tested among the elements of the page to be tested comprises:
Determining whether text content in the elements of the page to be tested comprises the elements of the text to be tested;
If the text content in the element of the page to be tested comprises the element of the text to be tested, taking the element as the first related element;
if the text content does not exist in the element of the page to be tested and comprises the element of the text to be tested, determining that the element of the page to be tested, the attribute value of which comprises the element of the text to be tested, is the first related element.
6. The method according to claim 1, wherein the method further comprises: obtaining an expected result;
The step of testing the page based on the test instruction comprises the following steps:
executing the test instruction and determining an execution result;
determining whether the execution result is consistent with the expected result.
7. A page testing apparatus, the apparatus comprising:
The acquisition module is used for acquiring 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 text content displayed in a page to be tested;
the determining module is used for determining target elements corresponding to the text to be tested from elements contained in the page to be tested;
the generation 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;
the test module is used for testing the page based on the test instruction;
the determination module is further to:
Searching a first related element comprising the text to be tested in the elements of the page to be tested;
screening out invisible elements in the first related elements, and taking the first visible elements in the first related elements as visible elements to be determined as target elements;
When more than one visible element is to be determined as a target element, taking the visible element with the highest correlation degree with the text to be tested as the target element, wherein the correlation degree is used for representing the ratio of the text lengths of the text to be tested and the visible element;
when the visible element to be determined as the target element is equal to one, the visible element is taken as the target element.
8. A computer readable medium on which a computer program is stored, characterized in that the program, when being executed by a processing device, carries out the steps of the method according to any one of claims 1-6.
9. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to carry out the steps of the method according to any one of claims 1-6.
CN202110513586.1A 2021-05-11 2021-05-11 Page test method and device, storage medium and electronic equipment Active CN113094286B (en)

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 CN113094286A (en) 2021-07-09
CN113094286B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114490395A (en) * 2022-01-27 2022-05-13 北京飞书科技有限公司 Test processing method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
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
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

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521121B (en) * 2011-11-18 2015-04-08 华为技术有限公司 Page testing method and page testing device
US9304892B2 (en) * 2013-06-03 2016-04-05 Sap Se Determining behavior models

Patent Citations (4)

* Cited by examiner, † Cited by third party
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
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

Also Published As

Publication number Publication date
CN113094286A (en) 2021-07-09

Similar Documents

Publication Publication Date Title
CN111274760B (en) Rich text data processing method and device, electronic equipment and computer storage medium
CN110489345B (en) Crash aggregation method, device, medium and equipment
CN112528595B (en) Document processing method and device and electronic equipment
CN109828906B (en) UI (user interface) automatic testing method and device, electronic equipment and storage medium
CN112836074B (en) Wallpaper display method and equipment
CN111813465B (en) Information acquisition method, device, medium and equipment
CN112287206A (en) Information processing method and device and electronic equipment
CN110390063A (en) A kind of data analysis method, device, medium and electronic equipment
CN113094286B (en) Page test method and device, storage medium and electronic equipment
CN111723309A (en) Method and device for searching web page
CN111353296B (en) Article processing method, apparatus, electronic device and computer readable storage medium
CN109992698B (en) Data processing method and device, electronic equipment and readable storage medium
CN112035092A (en) Form processing method, device, equipment and readable medium
CN110069186B (en) Method and equipment for displaying operation interface of application
CN110717126A (en) Page browsing method and device, electronic equipment and computer readable storage medium
CN114461214A (en) Page display method and device, electronic equipment and storage medium
CN110442403B (en) Method, device, electronic equipment and medium for calling functional component
CN112380476A (en) Information display method and device and electronic equipment
CN115756452A (en) Target page code generation method, device, storage medium and program product
CN111414106A (en) Title display method and device, electronic equipment and computer readable medium
CN112307723A (en) Method and device for generating code document and electronic equipment
CN114997120B (en) Method, device, terminal and storage medium for generating document tag
CN111309675B (en) Associated information display method and device, electronic equipment and storage medium
CN111338621A (en) Data display method and device, electronic equipment and computer readable medium
CN111310031B (en) House source information display method, device, terminal and storage medium

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