CN112149033A - Method and device for acquiring H5 page control, electronic equipment and storage medium - Google Patents

Method and device for acquiring H5 page control, electronic equipment and storage medium Download PDF

Info

Publication number
CN112149033A
CN112149033A CN202010962834.6A CN202010962834A CN112149033A CN 112149033 A CN112149033 A CN 112149033A CN 202010962834 A CN202010962834 A CN 202010962834A CN 112149033 A CN112149033 A CN 112149033A
Authority
CN
China
Prior art keywords
control
page
acquiring
page control
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010962834.6A
Other languages
Chinese (zh)
Inventor
金伟光
李秋林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings 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 JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN202010962834.6A priority Critical patent/CN112149033A/en
Publication of CN112149033A publication Critical patent/CN112149033A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • 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

Abstract

The application relates to a method and a device for acquiring an H5 page control, electronic equipment and a storage medium, which are applied to the technical field of computers, wherein the method comprises the following steps: receiving an acquisition instruction sent by a test terminal, acquiring a control in an application program to be tested according to the acquisition instruction, judging whether the control is a webpage view control, and acquiring an H5 page control in the webpage view control based on a preset H5 page acquisition code if the control is the webpage view control. The problem that in the related art, when webview versions on the mobile terminal are different, different webdriver drivers need to be downloaded, configuration convenience is low, and the configuration process is complex is solved.

Description

Method and device for acquiring H5 page control, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for acquiring an H5 page control, an electronic device, and a storage medium.
Background
With the development of computer technology, more and more application programs are developed and applied to various fields of society. After an application is developed, it needs to be tested to determine whether the application has defects. In the software automation test process, a control tree corresponding to software to be tested is generally obtained, so that a test on corresponding application performance and the like is realized based on finding a control in the control tree.
With the continuous development of the application programs, the number of H5 pages in the application programs is increased, and in order to realize the automatic test of the application programs, the H5 pages in the application programs need to be acquired. Typically, the H5 page needs to be loaded through a web view (webview). In the related art, the H5 page is acquired by starting a driver of a browser corresponding to the webview version and communicating with the browser by using a web driver (webdriver) protocol, so as to acquire the H5 page on the mobile terminal.
However, in this way, different browsers correspond to different webdrivers, so when webview versions on the mobile terminal are different, different webdriver drivers need to be downloaded, configuration convenience is not high, and the configuration process is complicated.
Disclosure of Invention
The application provides a method and a device for acquiring an H5 page control, electronic equipment and a storage medium, which are used for solving the problems that in the prior art, different webdriver drivers need to be downloaded when webview versions on a mobile terminal are different, configuration convenience is low, and a configuration process is complicated.
In a first aspect, an embodiment of the present application provides a method for acquiring an H5 page control, which is applied to a terminal to be tested, where an application program to be tested is installed in the terminal to be tested, and the method includes:
receiving an acquisition instruction sent by a test terminal;
acquiring a control in the application program to be tested according to the acquisition instruction;
judging whether the control is a webpage view control or not;
and if so, acquiring an H5 page control in the webpage view control based on a preset H5 page acquisition code.
Optionally, the acquiring an H5 page control in the web view control based on a preset H5 page acquisition code includes:
converting the webpage view control into a webpage view object so as to call a code injection interface through the webpage view object;
and injecting the preset H5 page acquisition code into the webpage view control through the code injection interface, and running the H5 page acquisition code in the webpage view control to acquire an H5 page control in the webpage view control.
Optionally, after the acquiring the H5 page control in the web page view control based on the preset H5 page acquisition code, the method further includes:
traversing the H5 page control, determining the boundary of the H5 page control;
judging whether the boundary is completely in the screen window;
if the boundary of the H5 page control is not in the screen window, filtering the H5 page control;
and if the boundary part of the H5 page control exists in the screen window, adjusting the parameters of the H5 page control so that the H5 page control is in the screen window.
Optionally, if the boundary portion of the H5 page control exists in the screen window, adjusting the parameter of the H5 page control, so that after the H5 page control is in the screen window, the method further includes:
and storing the H5 page control with the boundary in the screen window into a preset data structure, wherein the preset data structure is a data structure which can be recognized by a test terminal.
Optionally, after the storing the H5 page control whose boundary is within the screen window into a preset data structure, the method further includes:
and sending the preset data structure to the test terminal.
Optionally, before receiving the obtaining instruction sent by the test terminal, the method further includes:
and receiving a connection request sent by the test terminal, and establishing connection with the test terminal.
Optionally, the preset H5 page acquisition code is a JS code.
In a second aspect, an embodiment of the present application provides an apparatus for acquiring an H5 page control, including:
the receiving module is used for receiving an acquisition instruction sent by the test terminal;
the first acquisition module is used for acquiring a control in the application program to be tested according to the acquisition instruction;
the judging module is used for judging whether the control is a webpage view control or not;
and the second obtaining module is used for obtaining an H5 page control in the webpage view control based on a preset H5 page obtaining code when the control is the webpage view control.
Optionally, the second obtaining module includes:
the conversion module is used for converting the webpage view control into a webpage view object so as to call a code injection interface through the webpage view object;
a third obtaining module, configured to inject the preset H5 page obtaining code into the web view control through the code injection interface, and run the H5 page obtaining code in the web view control, so as to obtain an H5 page control in the web view control.
Optionally, the apparatus further includes:
a determining module, configured to traverse the H5 page control, and determine a boundary of the H5 page control;
the judgment submodule is used for judging whether the boundary is completely in the screen window;
a filtering module, configured to filter the H5 page control if the boundary of the H5 page control is not within the screen window;
and the adjusting module is used for adjusting the parameters of the H5 page control if the boundary part of the H5 page control exists in the screen window, so that the H5 page control is in the screen window.
Optionally, the apparatus further includes:
and the storage module is used for storing the H5 page control with the boundary in the screen window into a preset data structure, wherein the preset data structure is a data structure which can be identified by a test terminal.
Optionally, the apparatus further includes a determining module, configured to send the preset data structure to the test terminal.
Optionally, the apparatus for acquiring an H5 page control according to the embodiment of the present application further includes: and the connection module is used for receiving the connection request sent by the test terminal and establishing connection with the test terminal.
Optionally, the preset H5 page acquisition code is a JS code.
In a third aspect, an embodiment of the present application provides an electronic device, including: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor is configured to execute the program stored in the memory, and implement the method for acquiring the H5 page control according to the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the method for acquiring the H5 page control according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the method provided by the embodiment of the application, the acquisition instruction sent by the test terminal is received, the control in the application program to be tested is acquired according to the acquisition instruction, and the H5 page control in the web view control is acquired based on the preset H5 page acquisition code when the control is the web view control through judgment of the control type. Therefore, different webpage view controls do not need to be matched, webdriver drivers do not need to be downloaded, the H5 page control can be obtained through the preset H5 page obtaining code, the configuration process is simple, the obtaining flow of the H5 page control in the application program is simplified, and the obtaining efficiency of the H5 page control is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of an obtaining method of an H5 page control according to an embodiment of the present application;
fig. 2 is a flowchart of a method for acquiring an H5 page control according to another embodiment of the present application;
fig. 3 is a structural diagram of an apparatus for acquiring an H5 page control according to an embodiment of the present application;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
An embodiment of the present application provides an obtaining method of an H5 page control, where the method may be applied to any form of electronic equipment, such as a mobile terminal, where the mobile terminal is used as a tested terminal, and an application program to be tested is installed in the tested terminal. As shown in fig. 1, the method for acquiring the H5 page control includes:
step 101, receiving an acquisition instruction sent by a test terminal.
In some embodiments, a testing tool is installed in the testing terminal, and the testing tool is used for testing the application program to be tested of the tested terminal. The test tool generates an acquisition instruction and sends the acquisition instruction to the tested terminal by responding to the operation of a tester in the application program to be tested.
The tested terminal can be a mobile terminal, such as a mobile phone and a tablet computer; the test terminal may be a PC terminal.
And 102, acquiring a control in the application program to be tested according to the acquisition instruction.
In some embodiments, after receiving the obtaining instruction, the terminal to be tested starts to obtain the control in the application program to be tested corresponding to the obtaining instruction.
And 103, judging whether the control is a webpage view control.
In some embodiments, there are various ways to determine whether the acquired control is a webview control, and whether the acquired control is a webview control may be determined according to the type of the control. And the control type of the webview control is webview.
In this embodiment, the efficiency of acquiring the H5 page control in the application program to be tested can be improved by automatically judging whether the control is a webview control by the program and automatically switching different control acquiring modes for different controls.
The webview control is a native control provided by platforms such as Android or IOS, and can be used for loading and displaying an H5 page in the corresponding operating system for the application program to be tested. Therefore, whether the control is a webview control or not can be determined, so that whether the H5 page control exists in the control can be determined, and the control in the application to be tested can be acquired in different manners.
And 104, if yes, acquiring an H5 page control in the webpage view control based on a preset H5 page acquisition code.
In some embodiments, after the mobile terminal identifies the webview control, the mobile terminal acquires an H5 page control of the webview control based on a preset H5 page acquisition code. The preset H5 page obtaining code may be js (javascript) code.
It can be understood that there are various control types in the application program to be tested, and for a control type that is not a webview control, the control of this type is stored in a preset data format, so as to facilitate the identification of the subsequent PC end. The preset data format may be an XML format.
In this embodiment, an obtaining instruction sent by the test terminal is received, a control in the application program to be tested is obtained according to the obtaining instruction, and when the control is a web view control, an H5 page control in the web view control is obtained based on a preset H5 page obtaining code by judging the type of the control. Therefore, different webpage view controls do not need to be matched, webdriver drivers do not need to be downloaded, the H5 page control can be obtained through the preset H5 page obtaining code, the configuration process is simple, the obtaining flow of the H5 page control in the application program is simplified, in addition, whether the control is the webview control or not is automatically judged through the method, different control obtaining modes are automatically switched for different controls, and the efficiency of obtaining the H5 page control in the application program to be tested can be improved.
In another embodiment of the present application, an obtaining method of an H5 page control is provided, and an execution subject of the method may be a terminal device, such as a mobile terminal. In practical applications, the mobile terminal may include devices such as a mobile phone, a smart phone, a tablet computer, a notebook computer, a personal digital assistant, a portable multimedia player, a navigation device, and the like. It will be understood by those skilled in the art that the configuration according to the embodiments of the present disclosure can be applied to a fixed type terminal such as a digital television, a desktop computer, etc., in addition to elements particularly used for mobile purposes. The following description will be given by taking the tested terminal as a mobile phone terminal and the testing terminal as a PC terminal as an example.
As shown in fig. 2, the method for acquiring an H5 page control is applied to a terminal to be tested, where an application program to be tested is installed in the terminal to be tested, and the method includes:
step 201, receiving a connection request sent by a test terminal, and establishing a connection with the test terminal.
In some embodiments, since the test terminal (PC end) cannot directly communicate with the terminal to be tested (mobile phone end) through the port, the PC end needs to perform port forwarding before being connected to the mobile phone end to connect to the mobile phone end. Specifically, the mobile phone starts a communication server (socket server), the PC starts a communication client (socket client), and the PC actively connects to the mobile phone, so as to establish communication connection between the mobile phone and the PC.
Further, port forwarding at the PC side can be realized by an Android Debug Bridge tool (an Android Debug Bridge tools, adb tool). The adb tool is a command line window for interacting with a simulator or real device through a computer. And port forwarding is carried out on the PC end through the adb tool, so that communication between the PC end and the mobile phone end is completed.
Step 202, receiving an acquisition instruction sent by the test terminal.
In some embodiments, a testing tool is installed in the testing terminal, and the testing tool is used for testing the application program to be tested of the tested terminal. The test tool generates an acquisition instruction and sends the acquisition instruction to the tested terminal by responding to the operation of a tester in the application program to be tested.
And 203, acquiring a control in the application program to be tested according to the acquisition instruction.
In some embodiments, after receiving the obtaining instruction, the terminal to be tested starts to obtain the control in the application program to be tested corresponding to the obtaining instruction. The control type of the application program to be tested is various, the control type is not webview control, the control type is stored in an XML format, the control type is webview control, and a JS injection mode is adopted to obtain an H5 page control embedded in the webview control.
Step 204, judging whether the control is a webpage view control, if not, executing step 205; if yes, go to step 206.
In some embodiments, there are various ways to determine whether the acquired control is a webview control, and whether the acquired control is a webview control may be determined according to the type of the control. By automatically judging whether the control is a webview control or not by the program and automatically switching different control acquiring modes for different controls, the efficiency of acquiring the H5 page control in the application program to be tested can be improved.
The webview control is a native control provided by platforms such as Android or IOS, and can be used for loading and displaying an H5 page in the corresponding operating system for the application program to be tested. Therefore, whether the control is a webview control or not can be determined, so that whether the H5 page control exists in the control can be determined, and the control in the application to be tested can be acquired in different manners.
And step 205, storing the control in a preset data structure.
In some embodiments, the control which is not the webview control in the application program to be tested is stored in the preset data structure which can be identified by the test terminal, and after the control is subsequently sent to the PC terminal, the time for identifying the control by the PC terminal can be saved.
The preset data structure may be a data structure that can be recognized by the mobile phone, for example, but not limited to, XML format or json format. The XML format or the json format both represent the hierarchical relationship, so that the PC terminal can be more easily identified after receiving the data structure of the type.
Step 206, converting the web page view control into a web page view object, so as to call a code injection interface through the web page view object.
In some embodiments, since the webview control cannot directly call the interface for H5 page fetch code injection, the webview control is first converted into a webview object, and the interface for H5 page fetch code injection is called through the webview object.
Step 207, injecting a preset H5 page acquisition code into the webpage view control through the code injection interface, and running an H5 page acquisition code in the webpage view control to acquire an H5 page control in the webpage view control.
In some embodiments, the code injection interface is called through the webview object, the preset H5 page acquisition code is injected into the webview control, and the H5 page control in the H5 page is acquired by running the H5 page acquisition code.
The preset H5 page obtaining code may be js (javascript) code.
The H5 page control is obtained by adopting the JS injection mode, webdriver drive does not need to be downloaded, the configuration environment does not need to be considered, the obtaining flow of the H5 page control in the application program is simplified, and the obtaining efficiency of the H5 page control is improved.
And step 208, traversing the H5 page control, and determining the boundary of the H5 page control.
In some embodiments, to prevent the H5 page control tree from being too large, such that the usability of the H5 page control tree is reduced, useless controls in the retrieved H5 page controls may be filtered. Specifically, by traversing the acquired H5 page control, the attribute of each H5 page control can be acquired, so as to determine the boundary of each H5 page control.
Step 209, determining whether the boundary is completely within the screen window, and if not, executing step 210; if yes, go to step 211; if the boundary portion exists within the screen window, step 213 is performed.
In some embodiments, not every acquired H5 page control is useful for testing the application under test, and therefore, useless controls in the H5 page control need to be filtered to avoid too many useless controls. By judging whether the boundary of the H5 page control is completely in the screen window or not, whether the H5 page control is a useful control or not can be determined, the useful control is reserved, useless controls are filtered, the usability of the H5 page control tree can be improved, and the interference of the useless controls on the useful controls can be reduced.
Step 210, filtering H5 page controls.
In some embodiments, for H5 page controls whose boundaries are completely out of the screen window, i.e., useless controls, filtering such H5 page controls can avoid the H5 page control tree from being too large, and improve the usability of the control tree.
Step 211, keeping the H5 page control with the boundary in the screen window.
In some embodiments, when the boundary of the H5 page control is completely within the screen window, it indicates that the H5 page control is a useful control, and the type of control is reserved and stored in a preset data structure for the PC to recognize.
Step 212, adjust the parameters of the H5 page control so that the H5 page control is within the screen window.
In some embodiments, for an H5 page control that is partially within the screen window, to avoid the display being incomplete when the H5 page is rendered, the parameters of the H5 page control may be adjusted to have its boundaries completely within the screen window. The parameters of the H5 page control may include, but are not limited to, the size and coordinates of the H5 page control, among others.
Step 213, storing the H5 page control whose boundary is in the screen window into a preset data structure.
In some embodiments, the H5 page control completely within the screen window and within the screen window after the parameters are adjusted is stored in a preset data structure for easy recognition by the PC.
The preset data structure is the same as the preset data structure, and a control which is not a webview control in the application program to be tested and an H5 page control completely in the screen window are both stored in the preset data structure, so that the PC terminal can conveniently identify the control.
And step 214, sending the preset data structure to the test terminal.
In some embodiments, after the control is completely acquired by the tested terminal and the acquired control is assembled in the preset data structure, the preset data structure is sent to the test terminal, and the test terminal can analyze and record the control acquired by the tested terminal, so as to complete the test.
In this embodiment, after receiving an acquisition instruction sent by a test terminal, a terminal to be tested starts to acquire a control, and stores the control in a data structure in an XML format, and when the control is a webview control, the control is converted into a webview object, and a code injection interface is called, so that by injecting a JS code, an H5 page control is acquired and stored in the data structure in the XML format, and then the XML is sent to the test terminal. In the process, corresponding webdriver drivers do not need to be downloaded according to different webview versions, and whether the JS injection mode is started to acquire the H5 page control is automatically judged according to the program, so that the testing process is more automatic.
In a specific embodiment, the testing terminal is a PC terminal, the PC terminal is provided with a testing tool, the tested terminal is a mobile phone terminal, an application program to be tested is installed in the mobile phone terminal, the mobile phone terminal receives a connection request of the PC terminal and establishes a connection with the PC terminal, after the PC terminal establishes a connection with the mobile phone terminal, the testing tool generates an acquisition instruction by responding to an operation of a tester in the application program to be tested and sends the acquisition instruction to the mobile phone terminal, and after the mobile phone terminal receives the acquisition instruction, the testing tool starts to acquire a control in the application program to be tested and judges whether the control is a webview control.
And when the control is the webview control, the webview control is forcibly converted into a webview object, a code injection interface is called through the webview object, a JS code is injected through the code injection interface, and the H5 page control can be obtained after the JS code is executed. Because the H5 page control has a useless control, in order to avoid interference of the useless control, in this embodiment, the control whose boundary of the H5 page control is not in the screen window is filtered, and the parameters of the H5 page control whose boundary is not completely in the screen window are completely in the screen window, so that the useful control in the screen window is stored in the XML.
And when the control is not the webview control, directly storing the control into the XML. After the mobile phone terminal finishes acquiring the control in the application program to be tested, the XML storing the control is sent to the PC terminal, and after the PC terminal receives the XML, the control acquired by the mobile phone terminal can be analyzed and recorded, so that the test is finished.
In the process of acquiring the H5 page control, corresponding webdriver drivers do not need to be downloaded according to different webview versions, and the H5 page control is acquired by automatically judging whether to start JS injection according to a program, so that the test process is more automated.
Based on the same concept, an apparatus for acquiring an H5 page control is provided in this embodiment, and specific implementation of the apparatus may refer to the description of the method embodiment, and repeated details are not repeated, as shown in fig. 3, the apparatus mainly includes: a receiving module 301, a first obtaining module 302, a judging module 303 and a second obtaining module 304. Wherein:
the receiving module 301 is configured to receive an obtaining instruction sent by the test terminal.
In some embodiments, a testing tool is installed in the testing terminal, and the testing tool is used for testing the application program to be tested of the tested terminal. The test tool generates an acquisition instruction and sends the acquisition instruction to the tested terminal by responding to the operation of a tester in the application program to be tested.
The first obtaining module 302 is configured to obtain a control in the application program to be tested according to the obtaining instruction.
In some embodiments, after receiving the obtaining instruction, the terminal to be tested starts to obtain the control in the application program to be tested corresponding to the obtaining instruction. The control type of the application program to be tested is various, the control type is not webview control, the control type is stored in an XML format, the control type is webview control, and a JS injection mode is adopted to obtain an H5 page control embedded in the webview control.
The judging module 303 is configured to judge whether the control is a web view control.
In some embodiments, there are many ways to determine whether the acquired control is a webview control, and it may be determined whether the acquired control is a webview control according to the type of the control. And the control type of the webview control is webview. By automatically judging whether the control is a webview control or not by the program and automatically switching different control acquiring modes for different controls, the efficiency of acquiring the H5 page control in the application program to be tested can be improved.
The second obtaining module 304 is configured to, when the control is a web page view control, obtain an H5 page control in the web page view control based on a preset H5 page obtaining code.
In some embodiments, after the mobile terminal identifies the webview control, the mobile terminal acquires an H5 page control of the webview control based on a preset H5 page acquisition code. The preset H5 page obtaining code may be js (javascript) code.
In this embodiment, the receiving module 301 receives an obtaining instruction sent by the testing terminal, the second obtaining module 302 obtains a control in the application program to be tested according to the obtaining instruction, the determining module 303 determines the type of the control, and when the control is a web view control, the third obtaining module 304 obtains an H5 page control in the web view control based on a preset H5 page obtaining code. Therefore, different webpage view controls do not need to be matched, webdriver drivers do not need to be downloaded, the H5 page control can be obtained through the preset H5 page obtaining code, the configuration process is simple, the obtaining flow of the H5 page control in the application program is simplified, and the obtaining efficiency of the H5 page control is improved.
Optionally, the second obtaining module specifically includes:
the conversion module is used for converting the webpage view control into a webpage view object so as to call a code injection interface through the webpage view object;
a third obtaining module, configured to inject the preset H5 page obtaining code into the web view control through the code injection interface, and run the H5 page obtaining code in the web view control, so as to obtain an H5 page control in the web view control.
Optionally, the apparatus for acquiring an H5 page control according to the embodiment of the present application further includes:
a determining module, configured to traverse the H5 page control, and determine a boundary of the H5 page control;
the judgment submodule is used for judging whether the boundary is completely in the screen window;
a filtering module, configured to filter the H5 page control if the boundary of the H5 page control is not within the screen window;
and the adjusting module is used for adjusting the parameters of the H5 page control if the boundary part of the H5 page control exists in the screen window, so that the H5 page control is in the screen window.
Optionally, the apparatus for acquiring an H5 page control according to the embodiment of the present application further includes:
and the storage module is used for storing the H5 page control with the boundary in the screen window into a preset data structure, wherein the preset data structure is a data structure which can be identified by a test terminal.
Optionally, the apparatus for acquiring an H5 page control in this embodiment of the present application further includes a determining module, configured to send the preset data structure to the test terminal.
Optionally, the apparatus for acquiring an H5 page control according to the embodiment of the present application further includes: and the connection module is used for receiving the connection request sent by the test terminal and establishing connection with the test terminal.
Optionally, the preset H5 page acquisition code is a JS code.
Based on the same concept, an embodiment of the present application provides an electronic device, as shown in fig. 4, the electronic device mainly includes: a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 communicate with each other via the communication bus 404. Wherein, the memory 403 stores programs executable by the processor 401, and the processor 401 executes the programs stored in the memory 403, implementing the following steps:
receiving an acquisition instruction sent by a test terminal;
acquiring a control in the application program to be tested according to the acquisition instruction;
judging whether the control is a webpage view control or not;
and if so, acquiring an H5 page control in the webpage view control based on a preset H5 page acquisition code.
In this embodiment, an obtaining instruction sent by the test terminal is received, a control in the application program to be tested is obtained according to the obtaining instruction, and when the control is a web view control, an H5 page control in the web view control is obtained based on a preset H5 page obtaining code by judging the type of the control. Therefore, different webpage view controls do not need to be matched, webdriver drivers do not need to be downloaded, the H5 page control can be obtained through the preset H5 page obtaining code, the configuration process is simple, the obtaining flow of the H5 page control in the application program is simplified, and the obtaining efficiency of the H5 page control is improved.
Further, the application program is further configured to implement the following steps:
the acquiring of the H5 page control in the web page view control based on the preset H5 page acquisition code comprises:
converting the webpage view control into a webpage view object so as to call a code injection interface through the webpage view object;
and injecting the preset H5 page acquisition code into the webpage view control through the code injection interface, and running the H5 page acquisition code in the webpage view control to acquire an H5 page control in the webpage view control.
Further, after the acquiring the H5 page control in the web page view control based on the preset H5 page acquisition code, the method further includes:
traversing the H5 page control, determining the boundary of the H5 page control;
judging whether the boundary is completely in the screen window;
if the boundary of the H5 page control is not in the screen window, filtering the H5 page control;
and if the boundary part of the H5 page control exists in the screen window, adjusting the parameters of the H5 page control so that the H5 page control is in the screen window.
Further, if the boundary portion of the H5 page control exists in the screen window, adjusting the parameters of the H5 page control so that the H5 page control is in the screen window, further includes:
and storing the H5 page control with the boundary in the screen window into a preset data structure, wherein the preset data structure is a data structure which can be recognized by a test terminal.
Further, after the H5 page control whose boundary is within the screen window is stored in a preset data structure, the method further includes:
and sending the preset data structure to the test terminal.
Further, before receiving the obtaining instruction sent by the test terminal, the method further includes:
and receiving a connection request sent by the test terminal, and establishing connection with the test terminal.
Further, the preset H5 page acquisition code is a JS code.
The communication bus 404 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 404 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 4, but this does not indicate only one bus or one type of bus.
The communication interface 402 is used for communication between the above-described electronic apparatus and other apparatuses.
The Memory 403 may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the aforementioned processor 401.
The Processor 401 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc., and may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
In yet another embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, and when the computer program runs on a computer, the computer is caused to execute the method for acquiring the H5 page control described in the above embodiment.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes, etc.), optical media (e.g., DVDs), or semiconductor media (e.g., solid state drives), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for acquiring an H5 page control is applied to a tested terminal, wherein an application program to be tested is installed in the tested terminal, and the method comprises the following steps:
receiving an acquisition instruction sent by a test terminal;
acquiring a control in the application program to be tested according to the acquisition instruction;
judging whether the control is a webpage view control or not;
and if so, acquiring an H5 page control in the webpage view control based on a preset H5 page acquisition code.
2. The method for acquiring the H5 page control according to claim 1, wherein the acquiring the H5 page control in the web view control based on the preset H5 page acquisition code includes:
converting the webpage view control into a webpage view object so as to call a code injection interface through the webpage view object;
and injecting the preset H5 page acquisition code into the webpage view control through the code injection interface, and running the H5 page acquisition code in the webpage view control to acquire an H5 page control in the webpage view control.
3. The method for acquiring the H5 page control, according to claim 1, wherein after acquiring the H5 page control in the web view control based on the preset H5 page acquisition code, the method further comprises:
traversing the H5 page control, determining the boundary of the H5 page control;
judging whether the boundary is completely in the screen window;
if the boundary of the H5 page control is not in the screen window, filtering the H5 page control;
and if the boundary part of the H5 page control exists in the screen window, adjusting the parameters of the H5 page control so that the H5 page control is in the screen window.
4. The method for obtaining the H5 page control as claimed in claim 3, wherein if the boundary portion of the H5 page control exists in the screen window, the adjusting the parameter of the H5 page control so that the H5 page control is located in the screen window, further comprises:
and storing the H5 page control with the boundary in the screen window into a preset data structure, wherein the preset data structure is a data structure which can be recognized by a test terminal.
5. The method for acquiring the H5 page control, according to claim 4, wherein the step of storing the boundary after the H5 page control in the screen window is stored in a preset data structure further comprises:
and sending the preset data structure to the test terminal.
6. The method for acquiring the H5 page control according to claim 1, wherein before receiving the acquisition instruction sent by the test terminal, the method further comprises:
and receiving a connection request sent by the test terminal, and establishing connection with the test terminal.
7. The method for acquiring the H5 page control, according to any one of claims 1-6, wherein the preset H5 page acquisition code is JS code.
8. An apparatus for acquiring H5 page control, comprising:
the receiving module is used for receiving an acquisition instruction sent by the test terminal;
the first acquisition module is used for acquiring a control in the application program to be tested according to the acquisition instruction;
the judging module is used for judging whether the control is a webpage view control or not;
and the second obtaining module is used for obtaining an H5 page control in the webpage view control based on a preset H5 page obtaining code when the control is the webpage view control.
9. An electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor is used for executing the program stored in the memory and realizing the acquisition method of the H5 page control in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method for acquiring the H5 page control according to any one of claims 1-7.
CN202010962834.6A 2020-09-14 2020-09-14 Method and device for acquiring H5 page control, electronic equipment and storage medium Pending CN112149033A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010962834.6A CN112149033A (en) 2020-09-14 2020-09-14 Method and device for acquiring H5 page control, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010962834.6A CN112149033A (en) 2020-09-14 2020-09-14 Method and device for acquiring H5 page control, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112149033A true CN112149033A (en) 2020-12-29

Family

ID=73893707

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010962834.6A Pending CN112149033A (en) 2020-09-14 2020-09-14 Method and device for acquiring H5 page control, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112149033A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108399119A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 Browse serves kernel engine data processing, automatic test method and apparatus
CN108959062A (en) * 2017-05-22 2018-12-07 腾讯科技(深圳)有限公司 Web page element acquisition methods and device
CN109656827A (en) * 2018-12-17 2019-04-19 北京云测信息技术有限公司 A kind of control tree generation method and terminal device
CN109857659A (en) * 2019-01-23 2019-06-07 广州云测信息技术有限公司 A kind of operating method and device of control
US20190303269A1 (en) * 2018-03-28 2019-10-03 Layout.io Ltd Methods and systems for testing visual aspects of a web page
US20190392025A1 (en) * 2018-06-25 2019-12-26 Baidu Online Network Technology (Beijing) Co., Ltd. Page displaying method, apparatus based on h5 webpage, and computer readable storage medium
CN111475394A (en) * 2019-01-24 2020-07-31 阿里巴巴集团控股有限公司 Application testing method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108399119A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 Browse serves kernel engine data processing, automatic test method and apparatus
CN108959062A (en) * 2017-05-22 2018-12-07 腾讯科技(深圳)有限公司 Web page element acquisition methods and device
US20190303269A1 (en) * 2018-03-28 2019-10-03 Layout.io Ltd Methods and systems for testing visual aspects of a web page
US20190392025A1 (en) * 2018-06-25 2019-12-26 Baidu Online Network Technology (Beijing) Co., Ltd. Page displaying method, apparatus based on h5 webpage, and computer readable storage medium
CN109656827A (en) * 2018-12-17 2019-04-19 北京云测信息技术有限公司 A kind of control tree generation method and terminal device
CN109857659A (en) * 2019-01-23 2019-06-07 广州云测信息技术有限公司 A kind of operating method and device of control
CN111475394A (en) * 2019-01-24 2020-07-31 阿里巴巴集团控股有限公司 Application testing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
高磊等: "Android应用开发精解", 30 September 2012, 北京航空航天大学出版社, pages: 255 - 256 *

Similar Documents

Publication Publication Date Title
US10932106B2 (en) System, a method and a computer program product for automated remote control
WO2018223717A1 (en) Webpage front-end testing method, device, system, apparatus and readable storage medium
CN108717393B (en) Application program testing method and mobile terminal
US9152521B2 (en) Systems and methods for testing content of mobile communication devices
CN111782492B (en) Page first screen loading duration testing method and device, computer equipment and medium
CN106126424B (en) A kind of visual automated testing method of script, device and mobile terminal
CN111475417A (en) Automatic testing method, device, equipment and storage medium
CN109344066B (en) Method, system and terminal for testing browser page
CN108519935B (en) Board card testing method and device, readable storage medium and computer equipment
CN112115051A (en) Page traversal detection method, device and equipment for application and readable storage medium
CN104991847A (en) Memory leakage automatic testing method and apparatus and mobile terminal
CN112115055A (en) Multi-machine automatic testing method and device and computer equipment
CN109032705B (en) Application program execution method and device, electronic equipment and readable storage medium
CN115061912A (en) Test case generation and test method, system and medium
CN109344058B (en) Automatic small program testing method
CN110889116B (en) Advertisement interception method and device and electronic equipment
CN112149033A (en) Method and device for acquiring H5 page control, electronic equipment and storage medium
CN116662193A (en) Page testing method and device
RU2595763C2 (en) Method and apparatus for managing load on basis of android browser
CN107451047B (en) Browser function testing method and system and electronic equipment
CN112835761B (en) Live broadcast software performance data acquisition method and device, electronic equipment and storage medium
CN114741325B (en) Recording method and device of test script for application system test
CN109710531B (en) Application program auditing method, device and system, electronic equipment and storage medium
CN115422087A (en) Script generation method and device
CN113377601A (en) Method and device for sensing service start and stop of domestic system and electronic equipment

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co., Ltd