CN108959062B - Webpage element acquisition method and device - Google Patents

Webpage element acquisition method and device Download PDF

Info

Publication number
CN108959062B
CN108959062B CN201710363817.9A CN201710363817A CN108959062B CN 108959062 B CN108959062 B CN 108959062B CN 201710363817 A CN201710363817 A CN 201710363817A CN 108959062 B CN108959062 B CN 108959062B
Authority
CN
China
Prior art keywords
web page
target
plug
main process
program
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
CN201710363817.9A
Other languages
Chinese (zh)
Other versions
CN108959062A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710363817.9A priority Critical patent/CN108959062B/en
Publication of CN108959062A publication Critical patent/CN108959062A/en
Application granted granted Critical
Publication of CN108959062B publication Critical patent/CN108959062B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Abstract

The invention discloses a webpage element obtaining method and device, and belongs to the field of automatic testing. The method comprises the steps that a main process agent receives an acquisition command sent by a test application program, a target webpage element is acquired from a sub-process agent through a communication channel according to the acquisition command, and the main process agent transmits the acquired target webpage element back to the test application program. The main process agent is arranged in the main process of the application program to be tested, and the sub-process agent is arranged in the sub-process of the application program to be tested.

Description

Webpage element acquisition method and device
Technical Field
The embodiment of the invention relates to the field of automatic testing, in particular to a method and a device for acquiring webpage elements.
Background
The task of automatic testing of a Web page (World Wide Web) is generally to acquire Web page elements (english: Web elements), package the Web elements into Web page Element objects, and then simulate manual testing steps to operate the Web page Element objects.
At present, an android terminal (i.e., a terminal with an android operating system) supports a Web automation test mode, generally an Instrumentation test framework injection mode is adopted, and a test application and a tested application are run on the same terminal for example. As shown in fig. 1, the method for acquiring, by the test application 100, the target web page element 112 of the application under test 110 includes: the test application 100 injects a javascript (js) script in the robotiumweb.js file 102 into the host process 114 of the application 110 to be tested, and the application 110 to be tested executes the js script to obtain a Target web view (Target WebView)116 from the host process 114, extracts a Target web element 112 from the Target web view 116, and sends the extracted Target web element 112 to the test application 100, so that the test application 100 parses the obtained Target web element 112 and encapsulates the Target web element into the Target web element object 104.
In the Web automation test described above, the test application 100 can test only the host process 114 of the application under test 110. As shown in fig. 2, if the tested application 110 is independent of the logic related to executing the js script and acquiring the target Web page view 116 as a Web subprocess 118, the Web subprocess 118 and the host process do not share resources, i.e., the two processes are independent of each other. Since the target web page view 116 does not exist in the main process 114, and the main process 114 cannot acquire the target web page view 116 in the sub-process 118, after the robotiumweb.
Disclosure of Invention
In order to solve the problem that a current test framework cannot support after a tested application program puts logic related to a Web page into a subprocess to realize in the related art, the embodiment of the invention provides a method and a device for acquiring a webpage element. The technical scheme is as follows:
in a first aspect, a method for acquiring a web page element is provided, where the method includes:
a main process agent receives an acquisition command sent by a test application program, wherein the main process agent is a process agent arranged in a main process of the tested application program, and the acquisition command is used for indicating the tested application program to acquire a target webpage element of a target Web page;
the main process agent obtains the target webpage element from a sub-process agent through a communication channel according to the obtaining command, wherein the sub-process agent is a process agent arranged in a sub-process of the application program to be tested, and the communication channel is a communication channel between the main process agent and the sub-process agent, which is established according to an inter-process communication IPC mechanism;
and the main process agent transmits the acquired target webpage elements back to the test application program.
In a second aspect, an apparatus for acquiring a web page element is provided, the apparatus comprising:
the system comprises a receiving module, a test application program and a main process agent, wherein the receiving module is used for receiving an acquisition command sent by the test application program by the main process agent, the main process agent is a process agent arranged in a main process of the tested application program, and the acquisition command is used for indicating the tested application program to acquire a target webpage element of a target Web page;
an obtaining module, configured to obtain, by the main process agent, the target web page element from a sub-process agent through a communication channel according to the obtaining command, where the sub-process agent is a process agent provided in a sub-process of the application to be tested, and the communication channel is a communication channel between the main process agent and the sub-process agent, which is established according to an inter-process communication IPC mechanism;
and the return module is used for returning the acquired target webpage elements to the test application program by the main process agent.
In a third aspect, a terminal is provided, which includes a processor and a memory, where the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the web page element obtaining method according to any one of claims 1 to 7.
In a fourth aspect, there is provided a computer-readable storage medium having stored therein at least one instruction which is loaded and executed by a processor to implement the web page element obtaining method according to any one of claims 1 to 7.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
because the main process is provided with a main process agent and the subprocess is provided with a subprocess agent, the embodiment receives an acquisition command sent by the test application program through the main process agent, acquires a target webpage element from the subprocess agent through a communication channel according to the acquisition command, and transmits the acquired target webpage element back to the test application program; the main process and the sub-processes can carry out inter-process communication through respective process agents, and the main process can acquire the target webpage elements in the sub-processes from the sub-process agents through the main process agents, so that the test application program can receive the target webpage elements sent by the main process agents, and the test application program can carry out automatic test on the tested application program according to the packaged target webpage element objects.
Drawings
Fig. 1 is a schematic structural diagram of an implementation environment related to a method for acquiring a web page element in the related art;
fig. 2 is a schematic structural diagram of an implementation environment related to another method for acquiring a web page element in the related art;
fig. 3 is a schematic structural diagram of an implementation environment related to a method for acquiring a web page element according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for obtaining web page elements according to an embodiment of the present invention;
FIG. 5 is a flowchart of a method for obtaining web page elements according to another embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating a method for acquiring web page elements according to an embodiment of the present invention;
fig. 7 is a block diagram of a web page element acquisition apparatus according to an embodiment of the present invention;
fig. 8 is a block diagram of a web page element acquisition apparatus according to another embodiment of the present invention;
fig. 9 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Please refer to fig. 3, which illustrates a schematic structural diagram of a terminal related to a webpage element obtaining method according to an embodiment of the present invention. The terminal runs with a client, comprising: a test application 310 and a tested application 320.
The test application 310 refers to the application where the automated test code is located. The test application 310 sends a get command to the application under test 320 instructing the application under test 320 to get the target Web page element 325 of the target Web page. Optionally, the test application 310 sends an acquisition command to the application under test 320 by remotely calling the browser code RemoteWebUtils 311.
The application under test 320 refers to an application with web browsing capability, and the application under test may be an application of a social platform with web browsing capability, an instant messaging application, a shopping application, a payment application, and the like. For example, if the item to be tested by the testing application 310 is application a, the application under test 320 is an android application corresponding to application a.
The tested application program 320 comprises a main process 321 and a sub-process 322, wherein the main process 321 is a process in charge of resource management and/or system interaction in the tested application program 320, and the sub-process 322 is also called a Web process and is a process in charge of tasks related to Web pages; optionally, sub-process 322 is used to execute the js script and obtain a target Web page view of the target Web page.
Optionally, each process has its own address space, and the main process and the sub-process are independent from each other and do not share their own address spaces. Illustratively, each process includes at least one of a text region (text region) that stores code executed by the processor, a data region (data region) that stores variables and dynamically allocated memory used during process execution, and a stack (stack region) that stores instructions and local variables of the active procedure call.
For security reasons, processes associated with Web pages are often placed in sandboxes to limit the Javascript code to run only in the sandbox, thereby increasing the security of the browser. Therefore, in the related art, due to the existence of the sandbox mechanism, the host process cannot call the interface to operate on the resources in the sub-process to obtain the target web page element 325 in the sub-process.
In order to solve the above problem, in this embodiment, a main process 321 is provided with a main process proxy 323, a sub-process 322 is provided with a sub-process proxy 324, and a communication channel is established between the main process proxy 323 and the sub-process proxy 324, where the communication channel is established according to an inter-process communication IPC mechanism, so that the main process 321 and the sub-process 322 can communicate with each other through their respective process proxies. Illustratively, the main process agent is a function method set in the main process, and the sub-process agent is a function method set in the sub-process.
Optionally, the IPC mechanism is mainly used for communication between processes, there are many types of messages, and a communication channel established according to the IPC mechanism is used for communication between a main process agent and a sub-agent.
Optionally, the test application 310 sends an obtaining command to the main process agent 323 of the application under test 320 through the RemoteWebUtils311, and the main process agent 323 obtains the target web page element 325 from the sub-process agent 324 through the communication channel according to the obtaining command, and returns the target web page element 325 to the test application 310.
Alternatively, the terminal may be a mobile phone, a tablet computer, an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III, motion Picture Experts Group Audio Layer IV, motion Picture Experts Group Audio Layer 4), an MP4 player, a laptop computer, a desktop computer, or the like.
Referring to fig. 4, a flowchart of a method for acquiring a web page element according to an embodiment of the present invention is shown. The embodiment is exemplified by applying the web page element obtaining method to the implementation environment shown in fig. 3. The webpage element acquisition method comprises the following steps:
in step 401, the main process agent receives an acquisition command sent by the test application.
The test application program sends an acquisition command to a main process agent in the tested application program, wherein the acquisition command is used for indicating the tested application program to acquire a target webpage element of a target Web page; correspondingly, the main process agent receives the acquisition command; illustratively, the get command is a command (cmd) command.
Optionally, the obtaining command carries an operation identifier, where the operation identifier is used to indicate a content type obtained by the application under test. In one possible implementation, the correspondence between the operation identifier and the content type is stored in the form of an operation list, which is shown in table one. In the operation list, the content type corresponding to the operation identifier "01" is a "Web page element" of the Web page, the content type corresponding to the operation identifier "02" is a "Uniform Resource Locator (URL) link" of the Web page, and the content type corresponding to the operation identifier "03" is a "Web page title" of the Web page.
Watch 1
Operation mark Content type
01 Web page elements
02 URL link
03 Web page title
For example, when the acquisition command sent by the test application to the host process agent carries the operation identifier "01", the host process agent queries a "Web page element" whose content type is the Web page corresponding to the operation identifier "01" in the table, and then the host process agent determines that the content to be acquired is the target Web page element of the target Web page.
And step 402, the main process agent acquires the target webpage element from the sub-process agent through the communication channel according to the acquisition command.
Optionally, the main process agent forwards the received cmd command to the sub-process agent through the communication channel, the sub-process agent obtains a target webpage view in the sub-process according to the cmd command, extracts a target webpage element from the target webpage view, returns the target webpage element to the main process agent through the communication channel, and the main process agent receives the target webpage element.
The target webpage view is also called target WebView and is a control for loading and displaying a target Web page. The target Web page element is also called a target Web element, and is a Web page element extracted from the target Web page view.
In step 403, the main process agent returns the acquired target webpage elements to the test application.
Optionally, the target webpage element is a plurality of webpage elements in the target webpage, and includes at least one of a form, a radio button, a check box, a list box, an input box, a password box, a text box and a picture in the target webpage.
Optionally, after receiving the target webpage element sent by the sub-process agent, the main process agent returns the target webpage element to the test application program, and correspondingly, the test application program receives the target webpage element, analyzes the target webpage element, and encapsulates the target webpage element into a target webpage element object.
In summary, since the main process is provided with one main process agent and the sub-process is provided with one sub-process agent, in this embodiment, the main process agent receives the acquisition command sent by the test application program, acquires the target web page element from the sub-process agent through the communication channel according to the acquisition command, and transmits the acquired target web page element back to the test application program; the main process and the sub-processes can carry out inter-process communication through respective process agents, and the main process can acquire the target webpage elements in the sub-processes from the sub-process agents through the main process agents, so that the test application program can receive the target webpage elements sent by the main process agents, and the test application program can carry out automatic test on the tested application program according to the packaged target webpage element objects.
Referring to fig. 5, a flowchart of a method for acquiring a web page element according to an embodiment of the present invention is shown. The embodiment is exemplified by applying the web page element obtaining method to the implementation environment shown in fig. 1. The webpage element acquisition method comprises the following steps:
step 501, the test application sends an acquisition command to a host process agent in the application under test.
Step 502, the main process agent receives an acquisition command sent by the test application.
In step 503, the main process agent sends the obtaining command to the sub-process agent through the communication channel.
Optionally, the main process agent sends a cmd command to the sub process agent through the communication channel, and the sub process agent receives the cmd command.
Since the code supporting the Web automation test (including the logic related to executing the js script and acquiring the target Web page view) belongs to the test code, if the test code is externally issued along with the application under test when the application under test is issued, not only the installation package size of the application under test is increased, but also the security risk caused by the outgoing test code exists. Therefore, in this embodiment, the code supporting the Web automation test is implemented in a plug-in mode, the plug-in is not issued when the application under test is issued, and the plug-in is a program for supporting the Web automation test when the Web automation test is performed, so that only the code related to the main process agent and the sub process agent needs to be added to the application under test, and the security risk is controllable while the size of the installation package of the application under test is hardly increased.
Optionally, the main process agent sends a cmd command to the sub process agent through the communication channel, and the sub process agent receives the cmd command. After the sub-process agent receives the cmd command, whether a plug-in is installed in the terminal is detected, if the plug-in is installed, step 506 is executed, and if the plug-in is not installed, step 504 is executed.
And step 504, when detecting that the plug-in program is not installed, installing the plug-in program according to the plug-in installation package in the appointed directory.
Optionally, an android engineering process is adopted for development, and finally, a plug-in installation package is generated through compiling and stored in a specified directory of the terminal. And when detecting that the plug-in is not installed, searching the plug-in installation package in the specified directory, and installing the plug-in according to the plug-in installation package.
Step 505, set the default class loader of the plug-in program as the third party class loader.
When the browser kernel corresponding to the target Web page is the kernel defined by the third party, the default class loader of the plug-in program does not support the automatic test corresponding to the webpage view defined by the third party. Therefore, in order for the plug-in to be able to support the above situation, the default class loader of the plug-in is set as the third party class loader, which is a class loader provided by the third party software development kit SDK and extended based on the default class loader, and the third party SDK is an SDK integrated in the target Web page.
At step 506, the sub-process agent forwards the get command to the plug-in.
Optionally, the subprocess proxy calls a plug-in to obtain the target web page element according to the obtaining command, where the plug-in is a plug-in running in the subprocess.
And step 507, the plug-in program acquires the target webpage view according to the acquisition command and extracts the target webpage elements from the target webpage view.
Since the browser kernel corresponding to the target Web page is a kernel provided by the operating system or a kernel defined by a third party, the process of extracting the target Web page element from the target Web page view by the plug-in includes, but is not limited to, the following two implementation methods.
In a possible implementation method, when a browser kernel corresponding to a target Web page is a kernel provided by an operating system, a plug-in program acquires a first webpage view according to an acquisition command, and executes a first js script on the first webpage view to obtain a target webpage element, wherein the first js script is used for extracting the target webpage element from the first webpage view; wherein the first webpage view is a default webpage view provided by the operating system.
Optionally, taking the target webpage as an HTML page as an example for explanation, the sub-process calls the first JS script through the first interface, analyzes all the Web elements in the HTML page, stores at least one Web element in a JSON (JSON Object Notation) format character string, and then transmits at least one Web element to the sub-process through a callback method in the first interface.
Optionally, the target webpage elements extracted by the plug-in include a plurality of webpage elements, and are stored in a json array form, each element in the json array corresponds to one webpage element, and the data structure form of storage of the target webpage elements is not limited in this embodiment.
In another possible implementation method, when the browser kernel corresponding to the target Web page is a kernel defined by a third party, the plug-in program acquires a second Web page view defined by the third party according to the acquisition command, and executes a second js script on the second Web page view to acquire a target Web page element, wherein the second js script is used for extracting the target Web page element from the second Web page view; wherein the second web page view is a third party defined web page view. For details, reference may be made to the first possible implementation method, which is not described herein again.
And step 508, the plug-in program transmits the extracted target webpage elements back to the subprocess proxy.
Optionally, the plug-in program transmits the extracted target webpage element back to the subprocess proxy in a character string form of a preset format; illustratively, the preset format is a JSON format.
In step 509, the child process agent receives the target web page element returned by the plug-in.
And step 510, the subprocess agent transmits the acquired target webpage element back to the main process agent through a communication channel.
Optionally, the subprocess agent returns the acquired target webpage element to the main process agent in a character string form of a preset format.
In step 511, the main process agent receives the target webpage element returned by the sub-process agent.
In step 512, the main process agent returns the acquired target webpage elements to the test application program in a character string form of a preset format, where the preset format is a format that can be analyzed by the preset test application program.
Step 513, the test application receives the target web page element sent by the host process agent.
Step 514, the test application parses and encapsulates the target web page element into a target web page element object.
Optionally, the target webpage element object includes text information, attribute information, coordinate information, and the like of the target webpage element, and the attribute information includes: at least one of basic attribute of the target webpage element object, custom attribute of the target webpage element object and path information of the target webpage element object in the document. The basic attributes of the target webpage element object comprise an identification Id, a Name, a Class, a cascading style sheet Css, a Value and the like; the custom attribute of the target webpage element object is a third-party custom 'key-value', and the 'key' is different from the basic attribute name and is self-defined by the third party; the path information of the target webpage element object in the document is the extensible markup language path Xpath information.
In an illustrative example, as shown in FIG. 6, the test application 610 sends cmd commands to the main process agent 622 in the main process 621 of the application under test 620 through RemoteWebUtils611, the main process agent 622 sends cmd commands to the sub process agent 624 in the sub process 623 through IPC, the sub process agent 624 forwards the cmd commands to the plug-in 625, the plug-in 625 executes js scripts according to the cmd commands, extracts target web page elements from the acquired target web page view 626 and stores the target web page elements in the form of JSON arrays, and returns the return values to the sub process agent 624 using the JSON arrays as return values, the sub process agent 624 transmits the return values to the main process agent 622 through IPC, the main process agent 622 sends the return values to the test application 610 after acquiring the return values, and correspondingly, the test application 610 parses the return values to obtain the target web page elements, and packaging the target webpage elements into corresponding target webpage element objects.
In summary, since the main process is provided with one main process agent and the sub-process is provided with one sub-process agent, in this embodiment, the main process agent receives the acquisition command sent by the test application program, acquires the target web page element from the sub-process agent through the communication channel according to the acquisition command, and transmits the acquired target web page element back to the test application program; the main process and the sub-processes can carry out inter-process communication through respective process agents, and the main process can acquire the target webpage elements in the sub-processes from the sub-process agents through the main process agents, so that the test application program can receive the target webpage elements sent by the main process agents, and the test application program can carry out automatic test on the tested application program according to the packaged target webpage element objects.
In the embodiment, the code supporting the Web automation test is realized in a plug-in mode, and the plug-in is not issued when the application to be tested is issued, so that only the codes related to the main process agent and the sub process agent need to be added in the application to be tested, and the security risk is controllable while the size of the installation package of the application to be tested is hardly increased.
In the embodiment, when it is detected that the plug-in is not installed, the plug-in is installed according to the plug-in installation package in the specified directory, and the default class loader of the plug-in is set as the third-party class loader, so that when the browser kernel corresponding to the target Web page is the kernel defined by the third party, the class loader of the plug-in can support the corresponding automatic test, and the coverage of the tested application program on the automatic tests of different browser kernels is greatly improved.
The following are embodiments of the apparatus of the present invention that may be used to perform embodiments of the method of the present invention. For details which are not disclosed in the embodiments of the apparatus of the present invention, reference is made to the embodiments of the method of the present invention.
Referring to fig. 7, a schematic structural diagram of a web page element obtaining apparatus according to an embodiment of the present invention is shown. The web page element obtaining apparatus may be implemented by a dedicated hardware circuit, or a combination of hardware and software, as all or a part of the terminal in fig. 3, and includes: a receiving module 710, an obtaining module 720 and a returning module 730.
A receiving module 710, configured to implement step 401 or step 502 described above.
An obtaining module 720, configured to implement the step 402.
A backhaul module 730, configured to implement the step 403.
In an alternative embodiment provided based on the embodiment shown in fig. 7, as shown in fig. 8, the obtaining module 720 includes: a sending unit 721, a calling unit 722, a backhaul unit 723 and a receiving unit 724.
A sending unit 721, configured to implement step 503.
And the calling unit 722 is used for calling a plug-in program to acquire the target webpage element by the subprocess proxy according to the acquisition command, wherein the plug-in program is a plug-in program running in the subprocess.
A backhaul unit 723, configured to implement the step 510.
A receiving unit 724, configured to implement step 511 described above.
In an alternative embodiment provided based on the embodiment shown in fig. 7, as shown in fig. 8, the invoking unit 722 includes: a forwarding sub-unit 722a, an extracting sub-unit 722b, a returning sub-unit 722c and a receiving sub-unit 722 d.
A forwarding sub-unit 722a for implementing the step 506.
An obtaining subunit 722b, configured to implement step 507 above.
The returning subunit 722c is configured to implement the step 508.
A receiving subunit 722d, configured to implement step 509 as described above.
Optionally, when the browser kernel corresponding to the target Web page is a kernel provided by the operating system, the extracting subunit is further configured to, by the plug-in, obtain the first Web page view according to the obtaining command, execute the first js script on the first Web page view to obtain the target Web page element, where the first js script is used to extract the target Web page element from the first Web page view.
Optionally, when the browser kernel corresponding to the target Web page is a kernel defined by the third party, the extracting subunit is further configured to, by the plug-in program, obtain a second Web page view defined by the third party according to the obtaining command, execute a second js script on the second Web page view to obtain the target Web page element, where the second js script is used to extract the target Web page element from the second Web page view.
In an alternative embodiment provided based on the embodiment shown in fig. 7, as shown in fig. 8, the apparatus further includes: a setup module 740 and a setup module 750.
And an installation module 740 configured to implement step 504.
A setting module 750 for implementing the step 505.
In an alternative embodiment provided based on the embodiment shown in fig. 7, as shown in fig. 8, the backhaul module 730 is further configured to implement the step 512.
The relevant details may be combined with the method embodiments described with reference to fig. 3-6. The receiving module 710 is further configured to implement any other implicit or disclosed function related to the receiving step in the foregoing method embodiment; the obtaining module 720 is further configured to implement any other implicit or disclosed functionality related to the obtaining step in the foregoing method embodiments; the backhaul module 730 is further configured to implement any other implicit or disclosed functionality related to the backhaul step in the above method embodiments; the installation module 740 is further configured to implement any other implicit or disclosed functionality related to the installation step in the above method embodiments; the setup module 750 is also used to implement any other implicit or disclosed functionality related to the setup steps in the above method embodiments.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 9, which shows a block diagram of a terminal 900 according to an embodiment of the present invention, the terminal 900 may include RF (Radio Frequency) circuit 910, memory 920 including one or more computer-readable storage media, an input unit 930, a display unit 940, a sensor 950, an audio circuit 960, a WiFi (wireless fidelity) module 970, a processor 980 including one or more processing cores, and a power supply 990. Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 9 does not constitute a limitation of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 910 may be used for receiving and transmitting signals during a message transmission or call, and in particular, for receiving downlink information from a base station and then processing the received downlink information by the one or more processors 980; in addition, data relating to uplink is transmitted to the base station. In general, RF circuit 910 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuit 910 may also communicate with networks and other devices via wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), etc. Memory 920 may be used to store software programs and modules. The processor 980 executes various functional applications and data processing by running software programs and modules stored in the memory 920. The memory 920 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal 900, and the like. Further, the memory 920 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 920 may also include a memory controller to provide the processor 980 and the input unit 930 with access to the memory 920.
The input unit 930 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 930 may include a touch-sensitive surface 931 as well as other input devices 932. The touch-sensitive surface 931, also referred to as a touch screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 931 (e.g., operations by a user on or near the touch-sensitive surface 931 using a finger, a stylus, or any other suitable object or attachment) and drive the corresponding connecting device according to a predetermined program. Alternatively, the touch sensitive surface 931 may include both a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 980, and can receive and execute commands sent by the processor 980. In addition, the touch sensitive surface 931 may be implemented in various types, such as resistive, capacitive, infrared, and surface acoustic wave. The input unit 930 may also include other input devices 932 in addition to the touch-sensitive surface 931. In particular, other input devices 932 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 940 may be used to display information input by or provided to the user as well as various graphical user interfaces of the device 90, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 940 may include a Display panel 941, and optionally, the Display panel 941 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 931 may overlay the display panel 941, and when a touch operation is detected on or near the touch-sensitive surface 931, the touch operation is transmitted to the processor 980 to determine the type of touch event, and the processor 980 then provides a corresponding visual output on the display panel 941 according to the type of touch event. Although in FIG. 9 the touch-sensitive surface 931 and the display panel 941 are shown as two separate components to implement input and output functions, in some embodiments the touch-sensitive surface 931 and the display panel 941 may be integrated to implement input and output functions.
Terminal 900 can also include at least one sensor 950, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 941 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 941 and/or a backlight when the terminal 900 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal 900, the detailed description is omitted here.
Audio circuit 960, speaker 921, microphone 922 may provide an audio interface between a user and terminal 900. The audio circuit 960 can transmit the electrical signal converted from the received audio data to the speaker 921, and the electrical signal is converted into an audio signal by the speaker 921 for output; on the other hand, the microphone 922 converts the collected sound signals into electrical signals, which are received by the audio circuit 960 and converted into audio data, which are then processed by the audio data output processor 980, passed through the RF circuit 910 to be transmitted to another device, or output to the memory 920 for further processing. The audio circuit 960 may also include an earbud jack to provide communication of peripheral headphones with the terminal 900.
WiFi belongs to a short-distance wireless transmission technology, and the terminal 900 can help a user send and receive e-mails, browse webpages, access streaming media and the like through the WiFi module 970, which provides the user with wireless broadband internet access. Although fig. 9 shows the WiFi module 970, it is understood that it does not belong to the essential constitution of the terminal 900 and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 980 is a control center of the terminal 900, connects various parts of the entire device using various interfaces and lines, performs various functions of the terminal 900 and processes data by running or executing software programs and/or modules stored in the memory 920 and calling data stored in the memory 920, thereby monitoring the entire device. Optionally, processor 980 may include one or more processing cores; alternatively, processor 980 may integrate an application processor, which primarily handles operating systems, user interfaces, and applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 980.
The terminal 900 also includes a power supply 990 (e.g., a battery) for supplying power to the various components, which may be logically connected to the processor 980 via a power management system, for managing charging, discharging, and power consumption via the power management system. Power supply 990 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and the like.
Although not shown, the terminal 900 may further include a camera, a bluetooth module, etc., which will not be described herein.
The terminal 900 further includes a memory, in which at least one instruction is stored, and the instruction is loaded and executed by the processor to implement the web page element obtaining method provided by the above-mentioned method embodiments.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps in the web page element obtaining method for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing associated hardware, where the program may be stored in a computer-readable storage medium, and the storage medium stores at least one instruction, and the instruction is loaded and executed by a processor to implement the web page element obtaining method.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (12)

1. A method for acquiring webpage elements is characterized by comprising the following steps:
the method comprises the steps that a main process agent receives an acquisition command sent by a test application program, the main process agent is a process agent arranged in a main process of the tested application program, the acquisition command is used for indicating the tested application program to acquire a target webpage element of a target Web page, the tested application comprises a main process and a sub-process, the main process is used for indicating a process in charge of resource management and/or system interaction in the tested application program, the sub-process is used for indicating a process in charge of tasks related to the Web page, and the main process and the sub-process are independent of each other;
the main process agent sends the acquisition command to a sub process agent through a communication channel, wherein the sub process agent is a process agent arranged in a sub process of the application program to be tested, and the communication channel is a communication channel between the main process agent and the sub process agent, which is established according to an inter-process communication IPC mechanism;
the subprocess proxy calls a plug-in program to obtain the target webpage element according to the obtaining command, wherein the plug-in program is a plug-in program running in the subprocess;
the subprocess agent transmits the acquired target webpage element back to the main process agent through the communication channel;
the main process agent receives the target webpage elements returned by the sub process agents;
and the main process agent transmits the acquired target webpage elements back to the test application program.
2. The method of claim 1, wherein the sub-process agent invokes a plug-in to obtain the target web page element according to the obtaining command, comprising:
the subprocess agent forwards the acquisition command to the plug-in program;
the plug-in program acquires a target webpage view according to the acquisition command and extracts the target webpage elements from the target webpage view, wherein the target webpage view is a control for loading and displaying the target Web page;
the plug-in program transmits the extracted target webpage elements back to the subprocess proxy;
and the subprocess proxy receives the target webpage element returned by the plug-in program.
3. The method according to claim 2, wherein when the browser kernel corresponding to the target Web page is a kernel provided by an operating system, the plug-in obtains a target Web page view according to the obtaining command, and extracts the target Web page element from the target Web page view, including:
and the plug-in program acquires a first webpage view according to the acquisition command, and executes a first js script on the first webpage view to obtain the target webpage element, wherein the first js script is used for extracting the target webpage element from the first webpage view.
4. The method of claim 2, wherein when the browser kernel corresponding to the target Web page is a kernel defined by a third party, the plug-in obtains a target Web page view according to the obtaining command and extracts the target Web page element from the target Web page view, including:
and the plug-in program acquires a second webpage view defined by a third party according to the acquisition command, and executes a second js script on the second webpage view to obtain the target webpage element, wherein the second js script is used for extracting the target webpage element from the second webpage view.
5. The method of any of claims 1 to 4, further comprising:
when the plug-in is detected not to be installed, installing the plug-in according to a plug-in installation package in a specified directory;
and setting the default class loader of the plug-in program as a third-party class loader, wherein the third-party class loader is a class loader provided by a third-party Software Development Kit (SDK) and extended based on the default class loader, and the third-party SDK is an SDK integrated in the target Web page.
6. The method according to any one of claims 1 to 4, wherein the step of the host process agent returning the acquired target webpage element to the test application comprises:
and the main process agent transmits the acquired target webpage elements back to the test application program in a character string form of a preset format, wherein the preset format is a format which can be analyzed by the test application program.
7. An apparatus for acquiring web page elements, the apparatus comprising:
the system comprises a receiving module, a main process agent and a sub process, wherein the main process agent is a process agent arranged in a main process of an application program to be tested and used for receiving an acquisition command sent by the test application program, the acquisition command is used for indicating the application program to be tested to acquire a target webpage element of a target Web page, the application to be tested comprises the main process and the sub process, the main process is used for indicating a process in charge of resource management and/or system interaction in the application program to be tested, the sub process is used for indicating a process in charge of tasks related to the Web page, and the main process and the sub process are independent from each other;
an acquisition module, comprising: the device comprises a sending unit, a calling unit, a returning unit and a receiving unit;
the sending unit is used for sending the acquisition command to a subprocess proxy through a communication channel by the main process proxy, wherein the subprocess proxy is a process proxy arranged in a subprocess of the application program to be tested, and the communication channel is a communication channel between the main process proxy and the subprocess proxy, which is established according to an inter-process communication IPC mechanism;
the calling unit is used for calling a plug-in program to obtain the target webpage element by the subprocess proxy according to the obtaining command, wherein the plug-in program is a plug-in program running in the subprocess;
the return unit is used for the subprocess proxy to return the acquired target webpage element to the main process proxy through the communication channel;
the receiving unit is used for the main process agent to receive the target webpage elements returned by the sub-process agents;
and the return module is used for returning the acquired target webpage elements to the test application program by the main process agent.
8. The apparatus of claim 7, wherein the invoking unit comprises:
the system comprises a forwarding subunit, an extraction subunit, a returning subunit and a receiving subunit;
the forwarding subunit is configured to forward the obtaining command to the plug-in program by the subprocess agent;
the extracting subunit is configured to, by the plug-in, obtain a target Web page view according to the obtaining command, and extract the target Web page element from the target Web page view, where the target Web page view is a control for loading and displaying the target Web page;
the return subunit is configured to return, by the plug-in program, the extracted target webpage element to the subprocess proxy;
and the receiving subunit is used for receiving the target webpage element returned by the plug-in program by the subprocess proxy.
9. The apparatus according to claim 8, wherein when the browser kernel corresponding to the target Web page is a kernel provided by an operating system, the extracting subunit is further configured to, by the plug-in program, obtain a first Web page view according to the obtaining command, execute a first js script on the first Web page view to obtain the target Web page element, where the first js script is used to extract the target Web page element from the first Web page view.
10. The apparatus according to claim 8, wherein when the browser kernel corresponding to the target Web page is a kernel defined by a third party, the extracting subunit is further configured to, by the plug-in program, obtain a second Web page view defined by the third party according to the obtaining command, execute a second js script on the second Web page view to obtain the target Web page element, where the second js script is used to extract the target Web page element from the second Web page view.
11. A terminal, characterized in that the terminal comprises a processor and a memory, wherein the memory stores at least one instruction, and the instruction is loaded and executed by the processor to realize the webpage element obtaining method according to any one of claims 1 to 6.
12. A computer-readable storage medium having stored thereon at least one instruction which is loaded and executed by a processor to implement the web page element retrieving method according to any one of claims 1 to 6.
CN201710363817.9A 2017-05-22 2017-05-22 Webpage element acquisition method and device Active CN108959062B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710363817.9A CN108959062B (en) 2017-05-22 2017-05-22 Webpage element acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710363817.9A CN108959062B (en) 2017-05-22 2017-05-22 Webpage element acquisition method and device

Publications (2)

Publication Number Publication Date
CN108959062A CN108959062A (en) 2018-12-07
CN108959062B true CN108959062B (en) 2021-06-18

Family

ID=64461688

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710363817.9A Active CN108959062B (en) 2017-05-22 2017-05-22 Webpage element acquisition method and device

Country Status (1)

Country Link
CN (1) CN108959062B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111381903B (en) * 2020-03-18 2023-05-26 支付宝(杭州)信息技术有限公司 Program running method, device, equipment and medium
CN112149033A (en) * 2020-09-14 2020-12-29 京东数字科技控股股份有限公司 Method and device for acquiring H5 page control, electronic equipment and storage medium
CN114020490A (en) * 2021-08-30 2022-02-08 统信软件技术有限公司 Inter-process communication system and method and computing device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982068A (en) * 2012-10-25 2013-03-20 北京奇虎科技有限公司 Method for displaying recommended data and corresponding browser
CN102999613A (en) * 2012-11-28 2013-03-27 北京奇虎科技有限公司 Method and device for loading tool window in browser
CN104639534A (en) * 2014-12-30 2015-05-20 北京奇虎科技有限公司 Website safety information uploading method and browser device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9351193B2 (en) * 2009-01-28 2016-05-24 Headwater Partners I Llc Intermediate networking devices
US8682083B2 (en) * 2011-06-30 2014-03-25 American Express Travel Related Services Company, Inc. Method and system for webpage regression testing
CN105138448B (en) * 2014-06-05 2018-06-05 北京畅游天下网络技术有限公司 A kind of method and apparatus in the head end test page
CN104360936B (en) * 2014-10-17 2017-02-15 中国人民解放军国防科学技术大学 Barrier operation property analysis method based on triggering operation
US20160239880A1 (en) * 2015-02-17 2016-08-18 Pagefair Limited Web advertising protection system
CN105867984B (en) * 2016-04-22 2017-09-05 广州阿里巴巴文学信息技术有限公司 The method of show task status, device, client and mobile device in webpage
CN106095669B (en) * 2016-06-03 2020-09-25 中国矿业大学 Parallel program testing method based on scheduling sequence reduction

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982068A (en) * 2012-10-25 2013-03-20 北京奇虎科技有限公司 Method for displaying recommended data and corresponding browser
CN102999613A (en) * 2012-11-28 2013-03-27 北京奇虎科技有限公司 Method and device for loading tool window in browser
CN104639534A (en) * 2014-12-30 2015-05-20 北京奇虎科技有限公司 Website safety information uploading method and browser device

Also Published As

Publication number Publication date
CN108959062A (en) 2018-12-07

Similar Documents

Publication Publication Date Title
US9800609B2 (en) Method, device and system for detecting malware in a mobile terminal
US10853437B2 (en) Method and apparatus for invoking application programming interface
CN107040609B (en) Network request processing method and device
WO2017008551A1 (en) Bullet screen display method and apparatus
CN108536594B (en) Page testing method and device and storage equipment
CN109857403B (en) Page updating method and device, page processing method and device
WO2015096747A1 (en) Operation response method, client, browser and system
CN108039963B (en) Container configuration method and device and storage medium
CN107329901B (en) Data packet capturing method, terminal, server and storage medium
CN106547844B (en) A kind for the treatment of method and apparatus of user interface
CN105975190B (en) Graphical interface processing method, device and system
CN110020293B (en) Multimedia data display method, device and storage medium
CN104252356A (en) Interface generating method and system
CN108959062B (en) Webpage element acquisition method and device
EP2869604B1 (en) Method, apparatus and device for processing a mobile terminal resource
US9582584B2 (en) Method, apparatus and system for filtering data of web page
CN112749074B (en) Test case recommending method and device
CN108182090B (en) Flash plug-in loading method and device based on blink kernel
CN105631059B (en) Data processing method, data processing device and data processing system
CN105278942B (en) Component management method and device
CN111562910A (en) Packaging method and related equipment
CN109145598B (en) Virus detection method and device for script file, terminal and storage medium
CN110020338B (en) Browser and webpage opening method and device
CN109145182B (en) Data acquisition method and device, computer equipment and system
CN106201220B (en) Display content acquisition method and device

Legal Events

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