Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
When testing a webpage, testing each element in the webpage, such as inputting a frame element, testing correct display characters, limiting the length of the display characters and the like; multiple selection boxes or single selection box elements need to be tested for selecting or canceling functions; a link element, which needs to test a link clicking function; button elements, click functions that require test buttons, etc. Different elements all need to test different functional implementations.
FIG. 1 illustrates a flow chart of a method of locating web page elements according to one embodiment of the invention. As shown in fig. 1, the positioning method of the web page element specifically includes the following steps:
Step S101, an input character string containing a positioning keyword is received.
The web page includes a number of elements including an input box element for input, a button element, an element for providing link skip, a selection box element, text for prompting information, and the like. The login web page shown in fig. 2 displays prompt information characters such as a user name, a password, a user name and the like, corresponding input frame elements and radio frame elements are arranged beside the characters, and the web page also comprises button elements such as login, cancel and the like and a link element which returns to the upper page. The positioning keywords are derived from characters displayed in the webpage and can be characters used for prompting information, such as user names, passwords and the like; text in the link element, such as return to the upper page, is also possible; but also the text displayed by the button element, such as cancellation. Further, the positioning key may be part of the text displayed in the web page, such as a return.
And determining a positioning keyword according to the webpage element to be positioned, wherein the positioning keyword is related to the webpage element to be positioned. If the webpage element to be positioned is the input box of the password, the positioning keyword can be set as the password or the password. If the webpage element to be located is a login button, the location keyword may be set to be logged in. If the web page element to be located is a link element, the locating key word can be set to return to the upper page or return.
Step S102, judging whether the character string contains a position locator.
The character string may include a position locator in addition to the positioning keyword. The position locator is used for indicating the relative position of the positioning keyword and the webpage element to be positioned. As shown in fig. 2, when the web page element to be positioned is the input frame of the password, the position locator is the relative position of the password text and the input frame of the password when the positioning keyword is set as the password, the password input frame is on the right side of the password text, and the position locator is on the right side; when the positioning key words are set to memorize the user names, the position locator is the relative position of an input box for memorizing the user name characters and the passwords, the password input box is arranged on the upper side for memorizing the user name characters, and the position locator is arranged on the upper side. When the webpage element to be positioned is a login button, the positioning key word is set to be in the same position as the login button, so that a position locator is not required to be set; when the positioning key is set to cancel, the login button is on the left side of the canceling text, and the position locator is on the left side.
Judging whether the character string contains the position locator, if so, executing step S104, otherwise, executing step S103.
Step S103, traversing the webpage elements matched with the positioning keywords in the webpage.
And traversing the webpage elements in the webpage, and searching the webpage elements matched with the positioning keywords. When a webpage element login button is positioned through positioning keyword login, generating an object of a login webpage aiming at a website of the login webpage, traversing elements in the webpage object, and searching for the webpage element matched with the login.
Step S104, searching the web page elements consistent with the relative position of the positioning key words and the position locator indication.
When the character string contains the position locator, the search needs to search the web page element consistent with the relative position of the positioning key words and the indication of the position locator. The location of the locating key can be found by looking up the locating key, and further, the web page element located on the side indicated by the location locator of the locating key is looked up. If the element to be positioned is a user name input box, the user name input box element can be positioned by searching the position of the user name positioning keyword and searching the webpage element positioned on the right side of the user name positioning keyword.
When a plurality of webpage elements consistent with the relative positions of the positioning keywords and the position locator indication are searched, as shown in fig. 3, the webpage element to be positioned is a city input frame, the positioning keywords are searched as detailed addresses, and when the position locator is on the right side, the webpage element positioned on the right side of the detailed addresses is searched, so that the plurality of webpage elements of the city input frame, the district input frame and the county input frame can be found, and the webpage element with the nearest position distance to the positioning keywords is needed to be taken as the webpage element to be positioned. The coordinate data of a plurality of webpage elements of the city input frame, the district input frame and the county input frame are compared with the coordinate data of the detailed address, so that the nearest city input frame element with the coordinate data on the right side of the coordinate data of the detailed address can be determined as the webpage element to be positioned. Further, coordinate data of the positioning keywords in the webpage can be obtained by searching the positioning keywords. And searching the webpage elements positioned near the positioning keywords according to the coordinates of the positioning keywords. Web page elements that are consistent with the relative position of the positioning key and the position locator indication are screened from web page elements that are located near the positioning key. If the coordinate data of the detailed address in the webpage is found, searching all webpage elements positioned near the detailed address according to the coordinate data, wherein the webpage elements comprise a login name, a login name input box, a determination button and the like. From these web page elements, the city input box element located to the right of the coordinates of the detailed address is found from the coordinate data.
According to the webpage element positioning method provided by the invention, the input character string containing the positioning keywords is received, and the webpage elements matched with the positioning keywords can be positioned in a traversing mode. Further, when the position locator is specified, the web page element consistent with the relative position of the positioning keyword and the position locator indication is searched, and the web page element can be accurately positioned. When the webpage elements are positioned, the definition of the elements in the webpage codes is found without looking at the html, js and other codes in the webpage. The method can directly realize the positioning of the webpage elements from various information such as characters, position relations and the like displayed on the webpage, gets rid of the limitation that the positioning can be performed only by reading codes, and is simple and easy to execute.
FIG. 4 is a flow chart illustrating a method of locating a web page element according to another embodiment of the invention. As shown in fig. 4, the positioning method of the web page element specifically includes the following steps:
step S201, an input character string containing a positioning keyword is received.
Step S202, judging whether the character string is provided with a window identifier.
The character string may include a window identifier in addition to the positioning key and the position locator. The window is identified as a window title. When a plurality of webpages exist, for example, clicking a button or a link element in the webpage A, popping up the webpage B, and simultaneously, two webpages exist; or clicking a button or a link element in the webpage B, popping up the webpage C, and simultaneously, storing three webpages; or there may be cases where multiple web pages continue to be popped up. If an element to be positioned is searched, a plurality of webpages are searched due to the existence of the webpages, and more time is spent in searching the webpages; or when at least two web pages have the same web page elements, positioning errors easily occur when the web page elements are positioned. Therefore, in order to find more accurately and quickly, a window identifier, that is, a title of a web page window where a web page element to be positioned is located, can be set in the character string. Through the window identification, the search range of the element to be positioned can be accurately and rapidly limited in a specific webpage window. If the element to be located is in webpage B, the window is identified as the window title of webpage B.
If it is determined that the character string is provided with the window identifier, step S203 is performed. If the character string is judged to have no window identifier, the subsequent operation can continue to judge the character string, judge whether the character string contains the position locator, and if the character string contains the position locator, search the webpage element consistent with the relative position of the positioning keyword and the position locator indication. If the position locator is not included, traversing the webpage elements matched with the positioning keywords in the webpage.
Step S203, traversing the webpage elements matched with the positioning keywords in the window corresponding to the window identification.
If the character string is judged to be provided with the window identification, firstly traversing each window to find the window corresponding to the window identification. After the window is found, the subsequent operation can continue to judge the character string, judge whether the character string contains the position locator, if so, search the web page element consistent with the relative position of the positioning key words and the position locator indication in the window. If the position locator is not included, traversing the webpage elements matched with the positioning keywords in the window. The execution of step S203 may be referred to the descriptions of step S102-step S104, and will not be repeated here.
According to the webpage element positioning method provided by the invention, the plurality of webpage windows are positioned through the window identification, and then the element to be positioned is searched in the positioned windows, so that the time for searching the plurality of windows is reduced. And meanwhile, positioning errors caused by positioning the webpage elements when the same webpage elements exist in a plurality of webpages are avoided.
FIG. 5 illustrates a functional block diagram of a web page element locating apparatus according to one embodiment of the invention. As shown in fig. 5, the positioning device of the web page element includes the following modules:
The receiving module 301 is adapted to receive an input character string containing a positioning keyword.
The web page includes a number of elements including an input box element for input, a button element, an element for providing link skip, a selection box element, text for prompting information, and the like. The login web page shown in fig. 2 displays prompt information characters such as a user name, a password, a user name and the like, corresponding input frame elements and radio frame elements are arranged beside the characters, and the web page also comprises button elements such as login, cancel and the like and a link element which returns to the upper page. The positioning keywords are derived from characters displayed in the webpage and can be characters used for prompting information, such as user names, passwords and the like; text in the link element, such as return to the upper page, is also possible; but also the text displayed by the button element, such as cancellation. Further, the positioning key may be part of the text displayed in the web page, such as a return.
The positioning keywords are set according to the webpage elements to be positioned, and the positioning keywords received by the receiving module 301 are related to the webpage elements to be positioned. If the web page element to be located is the input box of the password, the location key received by the receiving module 301 is the password or the secret. If the web page element to be located is a login button, the location key received by the receiving module 301 is login. If the web page element to be located is a link element, the location key received by the receiving module 301 is returned to the upper page or returned.
The locator determination module 302 is adapted to determine whether the character string contains a location locator.
The character string may include a position locator in addition to the positioning keyword. The position locator is used for indicating the relative position of the positioning keyword and the webpage element to be positioned. As shown in fig. 2, when the element of the web page to be positioned is the input frame of the password, the position locator is the relative position of the password text and the input frame of the password when the positioning keyword received by the receiving module 301 is set as the password, the password input frame is on the right side of the password text, and the position locator is on the right side; when the positioning key received by the receiving module 301 is a user name, the position locator is a relative position of an input box for memorizing characters of the user name and passwords, the password input box is at the upper side for memorizing the characters of the user name, and the position locator is at the upper side. When the webpage element to be positioned is a login button, the positioning keyword received by the receiving module 301 is login, and the login text and the login button are located at the same place, so that a position locator is not required to be set; when the positioning key received by the receiving module 301 is cancel, the login button is on the left side of the cancel text, and the position locator is on the left side.
The locator determination module 302 determines whether the character string contains a location locator, if so, executes the locator search module 304, otherwise, executes the element traversal module 303.
The element traversing module 303 is adapted to traverse the web page elements matching the positioning keywords in the web page if the character string does not contain the position locator.
The element traversal module 303 traverses web page elements in the web page to find web page elements that match the locating keywords. When the element traversing module 303 locates the web page element login button by locating the keyword login, an object of the login web page is generated for the web address of the login web page, and the element traversing module 303 traverses the elements in the web page object to find the web page element matched with the login.
The locator search module 304 is adapted to search for a web page element consistent with the relative location of the location key and the location locator indication if the string contains a location locator.
When a position locator is included in the string, locator lookup module 304 looks up the web page element that is consistent with the relative position of the location key and the position locator indication. The locator search module 304 may find the location of the locating key by searching the locating key, and further, the locator search module 304 searches the web page elements located on the locator side of the location of the locating key. If the element to be located is a user name input box, the locator searching module 304 searches the location of the user name locating keyword, and searches the webpage element located on the right side of the location keyword, so that the user name input box element can be located.
When the number of the web page elements corresponding to the relative positions of the positioning keywords and the position locator indicates that the web page elements are multiple, as shown in fig. 3, the web page element to be positioned is a city input frame, the positioning keywords are detailed addresses, and when the position locator is on the right side, the locator searching module 304 searches the web page elements on the right side of the detailed addresses, and can find the multiple web page elements of the city input frame, the district input frame and the county input frame, and the web page element closest to the position of the positioning keywords is the web page element to be positioned. The coordinate data of a plurality of webpage elements of the city input frame, the district input frame and the county input frame are compared with the coordinate data of the detailed address, so that the nearest city input frame element of the coordinate data on the right side of the coordinate data of the detailed address is determined to be the webpage element to be positioned.
Further, the locator search module 304 further includes the following modules:
The coordinate acquisition module 3041 is adapted to acquire coordinates of the positioning keyword in the web page.
The element searching module 3042 is adapted to search the web page elements located near the positioning keyword according to the coordinates.
The element locating module 3043 is adapted to screen out the web page elements located near the locating key, which are consistent with the relative position of the locating key and the position locator indication.
The coordinate acquisition module 3041 searches for the positioning keyword, and acquires coordinate data of the positioning keyword in the web page. The element search module 3042 searches for web page elements located near the location key according to the coordinates of the location key. The element locating module 3043 screens out web page elements that are consistent with the relative position of the locating key and the position locator indication from among the web page elements that are located near the locating key. If the coordinate acquisition module 3041 finds the coordinate data of the detailed address in the web page, the element search module 3042 searches all the web page elements located near the detailed address according to the coordinate data, and the web page elements include login name, login name input box, determination button and the like. The element locating module 3043 finds the city input box element located on the right side of the coordinates of the detailed address from these web page elements according to the coordinate data.
According to the webpage element positioning device provided by the invention, the input character string containing the positioning keywords is received, and the webpage elements matched with the positioning keywords can be positioned in a traversing mode. Further, when the position locator is specified, the web page element consistent with the relative position of the positioning keyword and the position locator indication is searched, and the web page element can be accurately positioned. When the webpage elements are positioned, the definition of the elements in the webpage codes is found without looking at the html, js and other codes in the webpage. The method can directly realize the positioning of the webpage elements from various information such as characters, position relations and the like displayed on the webpage, gets rid of the limitation that the positioning can be performed only by reading codes, and is simple and easy to execute.
FIG. 6 illustrates a functional block diagram of a web page element locating apparatus according to another embodiment of the present invention. Compared with fig. 5, the difference is that the positioning device of the web page element further comprises:
the window identifier judging module 305 is adapted to judge whether a window identifier is set for the character string.
The character string may include a window identifier in addition to the positioning key and the position locator. The window is identified as a window title. When a plurality of webpages exist, for example, clicking a button or a link element in the webpage A, popping up the webpage B, and simultaneously, two webpages exist; or clicking a button or a link element in the webpage B, popping up the webpage C, and simultaneously, storing three webpages; or there may be cases where multiple web pages continue to be popped up. If an element to be positioned is searched, a plurality of webpages are searched due to the existence of the webpages, and more time is spent in searching the webpages; or when at least two web pages have the same web page elements, positioning errors easily occur when the web page elements are positioned. Therefore, in order to find more accurately and quickly, a window identifier, that is, a title of a web page window where a web page element to be positioned is located, can be set in the character string. Through the window identification, the search range of the element to be positioned can be accurately and rapidly limited in a specific webpage window. If the element to be located is in webpage B, the window is identified as the window title of webpage B.
If the window identifier judging module 305 judges that the window identifier is not set in the character string, the subsequent operation may continue to execute the locator judging module 302 to judge the character string, and if the locator judging module 302 judges that the character string contains the location locator, the locator searching module 304 searches the web page element consistent with the relative location of the locating keyword and the location locator indication. If the locator judgment module 302 judges that the character string does not contain the location locator, the execution element traversing module 303 traverses the web page element matched with the location keyword in the web page.
If the window identifier judging module 305 judges that the character string is provided with the window identifier, the locator judging module 302 continues to execute to judge the character string, and if the locator judging module 302 judges that the character string contains the position locator, the locator searching module 304 is executed to traverse each window to find the window corresponding to the window identifier. After finding the window, the web page elements in the window, which are consistent with the relative positions of the positioning keywords and the position locator indications, are found. If the locator judgment module 302 judges that the character string does not contain the location locator, the execution element traversing module 303 traverses each window to find the window corresponding to the window identifier. After finding the window, traversing the webpage elements matched with the positioning keywords in the window.
According to the webpage element positioning device provided by the invention, the plurality of webpage windows are positioned through the window identification, and then the element to be positioned is searched in the positioned windows, so that the time for searching the plurality of windows is reduced. And meanwhile, positioning errors caused by positioning the webpage elements when the same webpage elements exist in a plurality of webpages are avoided.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general-purpose systems may also be used with the teachings herein. The required structure for a construction of such a system is apparent from the description above. In addition, the present invention is not directed to any particular programming language. It will be appreciated that the teachings of the present invention described herein may be implemented in a variety of programming languages, and the above description of specific languages is provided for disclosure of enablement and best mode of the present invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component and, furthermore, they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, may be used in combination, except insofar as at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
Various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that some or all of the functions of some or all of the components in a positioning device for a web page element according to an embodiment of the invention may be implemented in practice using a microprocessor or Digital Signal Processor (DSP). The present invention can also be implemented as an apparatus or device program (e.g., a computer program and a computer program product) for performing a portion or all of the methods described herein. Such a program embodying the present invention may be stored on a computer readable medium, or may have the form of one or more signals. Such signals may be downloaded from an internet website, provided on a carrier signal, or provided in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order. These words may be interpreted as names.