CN104657377A - Multi-channel webpage control positioning method and device - Google Patents

Multi-channel webpage control positioning method and device Download PDF

Info

Publication number
CN104657377A
CN104657377A CN201310590812.1A CN201310590812A CN104657377A CN 104657377 A CN104657377 A CN 104657377A CN 201310590812 A CN201310590812 A CN 201310590812A CN 104657377 A CN104657377 A CN 104657377A
Authority
CN
China
Prior art keywords
control
target widget
thread
locator data
attribute
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310590812.1A
Other languages
Chinese (zh)
Other versions
CN104657377B (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.)
Alibaba Singapore Holdings Pte Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201310590812.1A priority Critical patent/CN104657377B/en
Publication of CN104657377A publication Critical patent/CN104657377A/en
Application granted granted Critical
Publication of CN104657377B publication Critical patent/CN104657377B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a multi-channel webpage control positioning method and device and relates to the webpage control positioning technology. The multi-channel webpage control positioning method comprises extracting an effective attribute pair set A of a target control; determining whether a control is contained in the current DOM (Document Object Model) structure or not, serving the set A as positioning data of the target control if not and indicating the position of the target control in a brother control through the index information if the control is contained in the current DOM structure and the control is the brother control of the target control, wherein a tag and an attribute set of the control are as same as those of the set A and the index information and the set A serve as the positioning data of the target control; extracting positioning data of a parent class control of the target control if the control is contained in the current DOM structure and the control is a non-brother control of the target control, wherein the positioning data of the parent class control and the set A serve as the positioning data of the target control; performing positioning on the target control according to the positioning data of the target control. The invention also discloses the multi-channel webpage control positioning device. According to the multi-channel webpage control positioning method and device, the stable control positioning is ensured and meanwhile the positioning efficiency is also ensured.

Description

A kind of multichannel webpage control localization method and device
Technical field
The present invention relates to webpage control location technology, particularly a kind of multichannel webpage control localization method and device.
Background technology
Along with the rise of internet, web2.0's is universal, all kinds of web application and relevant art development are rapidly, based on page test activity also more and more abundantizationer of web, automatic test particularly for the analog subscriber function of web webpage starts overall application and popularization, the selenium that picture industry is famous, the driver frameworks such as watir also arise at the historic moment, and these frameworks can drive browser and provide user's api interface to come operating browser and web page element thereof.Wherein most basic is exactly the location of webpage control, the locator meams that API provides also is tight format match, and such as, searching an ID is the control element button of AA, that abstract XPATH grammer is find_element (' XPATH ', ' //A [@id=AA] ').Or the mode of canonical coupling searches the element that a class attribute starts with BB, abstract grammer is find_element (' class ' ,/^BB/).Meanwhile, when single attribute can not uniquely be located, also support that the mode of Multiple Attribute Combinatorial carrys out accurate location element, such as find_element (' XPATH ', ' //A [@id=AAand@name=BB] ').So the atomic formula mode of searching on this basis can meet all element location, and also simultaneously, it is accurate formula.The implication of accurate formula refers to, control has multiple attribute and an XPATH path, we can by any attribute or multiple attributes or certain XPATH path can position matching to this control, but any one locator meams is all accurate after having chosen, such as locate with ID, then the ID of this element can not change.
Meanwhile, also have a class based on the technology sikuli of image recognition analog automatization, it is a kind of graphic programming mode, to the control on the page, as long as provide the areal map of control element, just this control can be navigated to, meanwhile, a series of analog mouse keyboard operation is carried out to the control of specifying.Its locator meams has a similarity parameter, and similarity is higher, also higher to the pixel request of matching area.Also searching and operating web page element can be realized by it, because be based on image recognition, on the machine of cross-platform or different resolution, supportive just poor.Generally, its web page element control recognition method is also accurate formula, once determine the picture region of a control, if the cosmetic variation of that this control, will cause identify less than or identification error.
Along with popularizing of these driver frameworks, in field tests, the automatic test part also Rapid Accumulation of UI, to saving manual test, application returns fast, provides efficient quality assurance to bring huge benefit.Release quickly for the Internet model provides the guarantee of high availability.
But meanwhile, because issue the quick renewal bringing webpage fast, dynamic web page element itself also may be change, just brings the variation in web page element attribute and XPATH path thus simultaneously.This just brings huge challenge to the web automatic test case located based on control element, and the change of control probably causes the location failure of control, thus causes the operation failure of case, and then is artificial this problem of reparation.Because this frequent variation, make these UI automatic tests case become heavyweight, the difficulty of maintenance also becomes the problem of headache, and such as one has CLASS, NAME, the element of ID etc., originally based on the test code of NAME location, if NAME variation, even if other element property are not changed, this element also can lose efficacy when locating, and code author just must find this to change point, and craft is by new effective NAME value or use other effective property values instead and position again.In the number of times occurred in this kind of problem is many, the maintenance cost brought just increases progressively, and also the robotization CASE searched based on control of let us or other instruments become heavyweight.
Meanwhile, when carrying out web automatic test, functional checking relatively easily realizes, but the monitoring of the problems such as the appearance style of the page is but difficult to accomplish, but but is need checking.Especially the control of some core business streams, show that style issues not only brings bad Consumer's Experience, even may affect the normal use of user, but on the checking of Page Views, or obtain the duplication of labour of repetitive manual, there is no the alternative or aid reserved to reduce this work artificially.
For this reason, just there are following technological challenge and demand, can change by fault-tolerant such control to a certain extent, even if make local attribute have change or html document relative position variation after, as long as other attributes do not changed of this element or path still effectively or outward appearance still effective, just still correctly can navigate to this control fast, simultaneously, for this control element, a mechanism can be had to monitor the change of its outward appearance, make in WEB automatic test, change if this control occurs that the normal appearance style of appearance style and script is compared, potential problem is there is with regard to meaning, what energy was correct informs user.
And the accurate formula matching way of the location employing regular coding of current control, the API namely located by control searches the element meeting certain attributes match or XPATH coupling.But the problem of which was once the matching condition chosen lost efficacy, and just cannot locate this element.Necessary manual intervention, replaces by new right value.Result in stability not high too large with maintenance cost.
Suppose there is control element E, its effective community set is S{a, b, c...}, the subset of its to be X.S1 in the XPATH path of current page document be S, is defined as and in current document, can uniquely can indicates element E. because S differs and uniquely indicates this element surely, so S1 may not exist by S1.(because do not affect the validity of derivation, supposing that S1 exists here).
Need now to search element E, that accurate formula matched and searched can exhaustive method as follows:
Find_element (XPATH): accurately search element E. by XPATH
Find_element (S1): by effective attribute to location element E.
Can learn from above:
When in XPATH path, any one node changes, accurately searching element E by XPATH will lose efficacy.
When in S1 set, any one attribute changes, also can be lost efficacy to location element E by effective attribute.
But in fact this element E is still effective, can by other attribute S2 in S, S3... correctly locates.Wherein, S2, S3... are S subset.
As can be seen from foregoing description, as long as current accurate formula matching way is when choosing any one change of attribute, will Wrong localization, stability is poor.
Summary of the invention
Technical matters to be solved by this invention is, provides a kind of multichannel webpage control localization method and device, to improve the stability of webpage control location.
In order to solve the problems of the technologies described above, the invention discloses a kind of multichannel webpage control localization method, the method comprises:
Extract effective attribute of target widget to set A;
In current file object model (DOM) structure, search label and community set and described effective attribute to the identical control of set A;
If found, and the control found and target widget are fraternal control, then adopt the position of index information indicating target control in fraternal control, and using this index information and described effective attribute to the locator data of set A as target widget;
If found, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and described effective attribute to the locator data of set A as target widget;
If do not found, then using described effective attribute to the locator data of set A as target widget;
Locator data according to described target widget positions target widget.
Alternatively, in said method, described effective attribute is at least comprising tag types, the label of control, property value in set A to sequence.
Alternatively, said method also comprises:
Also from described target widget, extract one or more information following, and the information of extraction added in the locator data of described target widget:
Cascading Style Sheet (CSS) selector switch information, active path information, page area figure information.
Alternatively, in said method, the locator data according to described target widget comprises the process that target widget positions:
When judging to include described index information in described locator data, set up multiple thread of searching and search described target widget simultaneously, the thread of searching set up at least comprises the attribute successively decreased and searches thread.
Wherein, when including described index information in described locator data, the thread of searching of foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Alternatively, in said method, the locator data according to described target widget comprises the process that target widget positions:
When judging not include described index information in described locator data, set up multiple thread of searching and search described target widget simultaneously, the thread of searching set up at least comprises partial circulating and searches thread and the attribute that increases progressively searches thread.
Wherein, when not including described index information in described locator data, the thread of searching of foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Alternatively, said method also comprises:
Monitor the control outward appearance of described target widget, when the control outward appearance of described target widget changes, the control outward appearance upgraded is analyzed and fed back to user.
The invention also discloses a kind of multichannel webpage control locating device, this device comprises:
Extraction module, extract effective attribute of target widget to set A, in current DOM structure, search label and community set and described effective attribute to the identical control of set A, if found, and the control found and target widget are fraternal control, then adopt the position of index information indicating target control in fraternal control, and using this index information and described effective attribute to the locator data of set A as target widget; If found, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and described effective attribute to the locator data of set A as target widget; If do not found, then using described effective attribute to the locator data of set A as target widget;
Locating module, the locator data according to described target widget positions target widget.
Alternatively, in said apparatus, described effective attribute is at least comprising tag types, the label of control, property value in set A to sequence.
Alternatively, in said apparatus, described extraction module, also extracts one or more information following, and the information of extraction is added in the locator data of described target widget from described target widget:
Cascading Style Sheet (CSS) selector switch information, active path information, page area figure information.
Alternatively, in said apparatus, described locating module comprises:
Judge module, judges whether include described index information in described locator data;
First processing unit, when having described index information in described locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises the attribute successively decreased and searches thread.
Alternatively, in said apparatus, the thread of searching of described first processing unit foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Alternatively, in said apparatus, described locating module also comprises:
Second processing unit, when not including described index information in described locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises partial circulating and searches thread and the attribute that increases progressively searches thread.
Alternatively, in said apparatus, the thread of searching of described second processing unit foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Alternatively, said apparatus also comprises, monitoring module, monitors the control outward appearance of described target widget, when the control outward appearance of described target widget changes, analyzes the control outward appearance upgraded and feeds back to user.
Technical scheme provides a kind of and extracts the total solution being defined into location algorithm and visual analysis feedback from abstract data, the core of location algorithm is to ensure to take into account location efficiency while more stably orient control, and makes test CASE maintenance cost lower.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of control localization method in the present embodiment 1;
Fig. 2 is the process flow diagram of control localization method in the present embodiment 2;
Fig. 3 is location algorithm process flow diagram in the localization method of control shown in Fig. 2;
Fig. 4 is the algorithm flow chart of the attribute finger increased progressively;
Fig. 5 is the algorithm flow chart of attribute finger of successively decreasing;
Fig. 6 is outward appearance monitoring flow journey schematic diagram in the present embodiment;
Fig. 7 is multichannel webpage control positioning device structure schematic diagram in the present embodiment.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly understand, hereafter will be described in further detail technical solution of the present invention by reference to the accompanying drawings.It should be noted that, when not conflicting, the feature in the embodiment of the application and embodiment can combine arbitrarily mutually.
The deficiency of technology is searched in order to make up existing control, strengthen the stability on control location and fault-tolerance, even if make local attribute have change or html document relative position variation after, as long as other attributes do not changed of this element or path still effectively or outward appearance still effective, just still correctly can navigate to this control fast, therefore when UI automatic test is applied, inventor proposes a kind of code being different from legacy controls location and writes pattern, but first extract a series of abstract datas of target widget, these data are equivalent to the metadata of target widget, then location algorithm and the strategy of more containment type is adopted, based on these metadata, the multi-threaded parallel location of self-align type is automatically carried out according to the community set of target widget.
Embodiment 1
The locator data extracted in the present embodiment is the set of properties set of target widget.Consider in some cases, there is multiple control in web page element, its property value, tag types (Tag name) is identical, only different unlike its parent control.In addition, have the control of identical attribute tags type under also there is same parent control, difference is only between each control different relative to the skew of parent control.Therefore, in order to can accurate orient control, 3 principles below demand fulfillment when extracting the locator data of target widget: the effective attribute 1, comprising this control is to set A (in practical application, the attribute pair that some are not suitable for being used as location can be filtered out, such as null value, style attribute etc., principle removes to hold labile attribute)
If in 2 current DOM structures, there is such control, its label is identical to set A with effective attribute of target widget with community set, and with target widget is the control of brother, namely cannot determine it is which control only by label and attribute, then need newly-increased index (index) to represent the position of target widget in fraternal control in the locator data of this target widget.
If in 3 current DOM structures, there is such control, its label is identical to set A with effective attribute of target widget with community set, but is its fraternal control; Which parent control needs the locator data of newly-increased parent control in the locator data of then this target widget, be under in order to limit this target widget.Wherein, target widget the locator data of parent control, adopt the above-mentioned rule of 1,2 and 3 to extract equally.
Based on above-mentioned thought, a kind of multichannel webpage control positioning and monitoring method that the present embodiment provides, as shown in Figure 1, at least comprises following operation:
Step 101, extracts effective attribute of target widget to set A;
In the present embodiment, effective attribute at least comprises the label of control, tag types, property value to sequence (Attribute_pairs) to set A.
Step 102, in current DOM structure, searches label and community set and effective attribute to the identical control of set A;
Step 103a, when finding, and when the control found and target widget are fraternal control, adopts the position of index information indicating target control in fraternal control, and using this index information and effective attribute to the locator data of set A as target widget;
Step 103b, when finding, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and effective attribute to the locator data of set A as target widget;
Wherein, when extracting the locator data of the parent control of target widget, parent control can be repeated the operation of above-mentioned steps 101 to 103 to extract locator data as new target widget.
And when target widget does not have parent control, the locator data of the parent control in locator data is configured to sky, namely illustrate that the location of target widget is whole html document scope.
Step 103c, if do not found, then using effective attribute to the locator data of set A as target widget;
Step 104, the locator data according to target widget positions target widget.
Wherein, when positioning operation according to locator data to target widget, can adopt any-mode, this is not restricted for the present embodiment.
It should be noted that, in order to ensure the stability that control is located, can also CSS selector switch and/or active path information (xpath) be added in locator data, using as an alternative approach when self-adjusting location algorithm can not find target widget.
In addition, for target widget, need a mechanism to monitor the change of its outward appearance, because in WEB automatic test, change if the appearance style of target widget is compared with initial pattern, just may there are the potential problems affecting control location.Therefore, the page area figure information of target widget can be added in locator data, thus the outward appearance of monitoring objective control, and when the outward appearance of target widget changes, this change is carried out to analysis and fed back to user in time.
In sum, based on the above method, preferred version, when extracting locator data, can also extract one or more information following, and the information of extraction be added in the locator data of described target widget:
CSS selector switch information, xpath, page area figure information.
Embodiment 2
3 rules that the present embodiment will meet based on the locator data extracting target widget in embodiment 1, provide a kind of preferred multichannel webpage control positioning and monitoring method, as shown in Figure 2, at least comprise following operation:
Effective attribute of step 201, extraction target widget is to set A;
This step is exactly filter out the attribute pair that some are not suitable for being used as location, such as null value, style attribute etc., thus the effective attribute obtaining target widget is to set.
In the present embodiment, effective attribute at least comprises the label of control, tag types, property value to sequence (Attribute_pairs) to set A.
Step 202, in current DOM structure, judge whether that effective attribute that can find label and community set and target widget is to the identical control of set A, if can find, then enter step 203, if search less than, then effective attribute of target widget is defined as the locator data of target widget to set A, enters step 206;
Step 203, whether the control that judgement finds and target widget are fraternal control, if so, then enter step 204, otherwise enter step 105;
Step 204, adopts the position of an index (index) information indicating target control in fraternal control, and effective attribute of target widget is defined as the locator data of target widget to set A and index information, enter step 206.
Step 205, extracts the locator data of the parent control of this target widget, and the locator data of the parent control extracted and effective attribute of target widget are defined as the locator data of target widget to set A;
In this step, when extracting the locator data of the parent control of target widget, can the operation of above-mentioned steps 101 to 105 be adopted to extract locator data as new target widget parent control.
As can be seen from aforesaid operations, for the control that some multiplicity is high, its locator data may form a Data-Link, considers search performance and validity, and chain length is more short better, namely meets as far as possible and represents target widget by the mode of the minimum chain of length.Oversize chain, wherein any one node is wrong just may affect whole chain, but does not do mandatory requirement, namely preferably, selects shorter control chain.The structure being the locator data of a target widget as follows:
Can find out, this structure above-mentioned is a Data-Link.The control of begin chain to be parent be null, such as, represent a link control by json data, its possible locator data is:
In addition, CSS selector switch or xpath are also frequently applied searching of target widget.Therefore in order to ensure the stability that control is located, these 2 extra control information can be added in locator data in preferential treatment scheme, as an alternative approach when self-adjusting location algorithm can not find target widget.
Further, if the appearance style of a certain control changes, the problem of potential impact location may be there is.Therefore the page area figure information of target widget also can add in locator data, and this pictorial information not only may be used for control location, can also be used for the monitoring of control outward appearance.But do not have it not affect control location to a certain extent, so be optional additional data yet yet.When comprising page area figure information in locator data, when occurring to change according to the outward appearance of this page area figure INFORMATION DISCOVERY target widget, the control outward appearance upgraded being analyzed and feeding back to user.
Step 206, positions operation according to determined locator data to target widget.
Locator data due to target widget is bar chain, and that is, the location of any one control is all the offspring's control based on its parent control.The father of top control is linked as sky.
So the position fixing process of the target widget in the present embodiment is the process of an iterative recursive, and from top control, iteration finally finds the leaf control of bottom.And the input of this iterative recursive operation is the locator data (locator data of parent control may be sky, for namely sky illustrates that current lookup is whole html document scope) of target widget, exporting is then the target widget navigated to.Again by this result as the parent control inputted next time, to circulate this process as son together with next target widget.Till iterating to leaf elements.In the present embodiment, provide a kind of location algorithm of optimization, as shown in Figure 3, comprise following operation:
Step 301, the locator data of input target widget.
Step 302, judges the positional information of indicating target control in fraternal control whether having index(and said method to add in locator data), if do not had, then enter step 303, if had, enter step 307;
In this step, selecting corresponding lookup algorithm according to judged result, is because if there is index to have multiple child control under the parent control of target widget, although this parent control not necessarily direct father, has multiple control to have identical set of properties.Namely illustrate that the result that found by the set of properties of target widget is also many, then location algorithm is different.
Step 303, main thread group of distributors is set up multiple thread of searching and is searched target widget simultaneously, and that sets up searches one or more that thread at least comprises in following 5 kinds:
A, partial circulating (Short-circuit): may to there being multiple thread, because one is effectively searched attribute and is exactly one and searches the factor (information namely in locator data), therefore set up a thread for each factor of searching.Than if any ID, NAME, then have 2 to search thread, search the element of ID and NAME coupling respectively, any one finds and only equals the result of, then return this control, otherwise returns sky.
Short-circuit finger sets of threads: be that its location algorithm is as follows in order to navigate to object element quickly:
Locator data S set { a, b, the c} of hypothetical target control
Then each information is one and searches the factor, supposes there are 3 factors.Each factor pair answers a thread, respectively the element of this matching attribute of parallel search.
Thread is searched for the single factor, if find object element to be empty, then returns sky.If search multiple element, because cannot determine it which is, also return sky.Iff finding an element, then can release the result that the attribute finger by increasing progressively finds also is this, because it is unique.
This finger has certain fault-tolerance, such as, in the S set change of any one information, and the information may do not become by other finds target widget.
When there being index, illustrating that the control of locating out by it must be multiple, so when there being index, not using Short-circuit finger.
B, the attribute finger increased progressively: a thread, take from multiple information that locator data comprises, get 2 information and be increased to the mode that all information goes coupling gradually, reduce seek scope gradually and positioning result.
Being the process flow diagram of the attribute finger for increasing progressively shown in Fig. 4, can being learnt by Fig. 4, in iterative process, the time overhead of algorithm is N (N is the number of element property)
Initial sets S{A, B ... and initial empty set S2{};
Circulation takes out an element from S, if be empty, then return and searches control failure;
This element is added searching of S2 concentrated (in fact the set of searching of S2 is understood from 2 combinations of attributes, because 1 attribute has been searched in Short-circuit, here in order to describe unification, assuming that from 1).
By the set search control of S2, the sequence of sets in S2 is AND operation.Namely suppose there is A, B, that is searched successful attribute and meets A & & B.
If find unique single control, then think and search successfully, return this control.If find sky control, then think, this thinks that the information newly added fails, then remove this information.If find multiple control, then think that current combinations of attributes can't uniquely be located, continue to attempt a newly-increased attribute and reduce the scope.
C, XPATH attribute finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.Search for providing a redundancy when other fingers are come to nothing.But because XPATH easily changes, this result reliability is low.So only as segmented result.
D, CSS finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.CSS finger uses the grammer of css selector switch, and speed comparatively attribute increase and decrease finger is good, and stability is better than xpath, can as extra matching way.
E, figure script (SIKULI) finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.Use the picture recognition engine of sikuli to carry out control coupling, the result of its coupling is different with the result type that other selector switchs return, so be also thereafter the mouse-keyboard operation of being correlated with sikuli to the operation of this result.The result of this finger is also the important foundation of the result of control outward appearance monitoring.
Step 304, judge in thread A, B and D, whether any one thread finds control, if found, the control found is target widget, if all do not found, enters step 305;
Step 305, judges whether thread C finds control, if found, the control found is target widget, if do not found, enters step 306;
Step 306, uses the result of result as positioning action of the picture recognition in thread E, and terminates whole positioning flow.
Each bar thread parallel of setting up is searched, and main thread does not need to wait for that all threads terminate just to terminate.As long as any one thread except XPATH attribute finger has the result of non-NULL to return, then think and have found this control.Short-circuit just attempts once in general, if hit, return, it is fastest.The attribute finger increased progressively can attempt combinations of attributes, comparatively slow.
If Short-circuit, the attribute finger increased progressively and CSS finger all could not find control, then return the result of XPATH.If XPATH also returns sky, with reference to the result of sikuli selector switch, if sikuli selector switch successful match, then return the result of picture recognition type, otherwise all fingers all fail to mate element, then search control failure.
Step 307, main thread group of distributors, sets up multiple thread of searching and searches element simultaneously, and that sets up searches one or more that thread at least comprises in following 4 kinds:
F, the attribute finger successively decreased: a corresponding thread, take to choose successively information from multiple information that locator data comprises and join and search in set, take until all information that locator data comprises are successively decreased.
The attribute finger successively decreased, with to increase progressively finger similar, is not uniquely both, its can choose from S complete or collected works always attribute add search collection and, until S attribute is decremented to only empty.Because adopt the attribute finger successively decreased to be having the situation of index, then illustrate searching in the combination of current effective attribute can be multiple control, decides which is by index.So must find the attribute maximum set of coupling, otherwise possibility index is to the scope element that should not have.Successively decrease attribute finger algorithm as shown in Figure 5:
Get from S an information add search collection S2, searched by S2.
If the result set found is the scope of index energy index, deposit this interim findings.Otherwise, from S2, remove this information.
Whether S is decremented to empty set, if not empty set, be recycled to start operation, then get from S an information add search collection S2 continue to search, if empty set, selection result.
If interim findings set exists, then return the index element of interim findings set.Otherwise, return sky, search unsuccessfully.
C, XPATH attribute finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.Search for providing a redundancy when other fingers are come to nothing.But because XPATH easily changes, this result reliability is low.So only as segmented result.
D, CSS finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.The mode of css selector switch is used to search control, because css selector switch is usually more stable and uniqueness better, so provide this redundancy finger.
E, SIKULI finger (this searches thread for optional): a corresponding thread, just uses when providing this redundant field.Use the picture recognition engine of sikuli to carry out control coupling, the result of its coupling is different with the result type that other selector switchs return, so be also thereafter the mouse-keyboard operation of being correlated with sikuli to the operation of this result.The result of this finger is also the important foundation of the result of control outward appearance monitoring.
Step 308, judges whether thread F or D finds control, if found, the control found is target widget, if all do not found, enters step 309;
Step 309, judges whether thread C finds control, if found, the control found is target widget, if do not found, enters step 310;
Step 310, uses the result of result as positioning action of the picture recognition in thread E, and terminates whole positioning flow.
Namely set up each bar thread parallel is searched, and main thread does not need to wait for that all threads terminate just to terminate.As long as any one thread except XPATH attribute finger has the result of non-NULL to return, then think and have found this control.If add sikuli finger, then can wait for the result of sikuli finger, because this result can as the foundation of control cosmetic variation monitoring.This finger speed is very fast, and the result that can not affect main thread is corresponding.
If increase progressively the attribute finger that subtracts and CSS finger all could not find element, then return the result of XPATH.
If XPATH also returns sky, with reference to the result of sikuli selector switch, if sikuli selector switch successful match, then return the result of picture recognition type, otherwise all fingers all fail to mate element, then search element failure.
Wherein, when containing the web page area figure of target widget in locator data, the outward appearance of control can be provided to monitor simultaneously.Monitoring logic as shown in Figure 6:
SIKULI picture engine positions control, if locate successfully, then represents the outward appearance of control and unchanged.
If locate unsuccessful, then judge that whether other non-SIKULI are successful based on the locator meams (the attribute finger increased progressively, CSS, XPATH etc.) of web, if unsuccessful, represent that the outward appearance of control and built-in attribute all there occurs nonlocalizable change.Nonlocalizable change information is returned user.
If locate successfully, take other modes and locate successful result, represent that control outward appearance changes, but the mode that inside still can be searched by attribute navigates to this control.The cosmetic variation of control may be potential bug risk.
By the control obtained, obtain the coordinate+size information of control.
Sectional drawing is carried out to the appointment size area of this coordinate position.(usually can carry out sectional drawing according to certain exaggerated scale).
Prompting control change and this control information of sectional drawing is returned in displaying user.
By this mode, just in automation process, except verifying the functional availability of webpage, also can carry out the outward appearance monitoring of critical function control simultaneously.
In addition, consider that the DOM being mainly used in browser searches or operates, in order to well support multiple different browsers product.In a particular application, use the programming language of javascript and the Driving technique of similar selenium, best implementation result can be reached.Need to encapsulate calling of java class libraries to calling of sikuli, ruby, python, java can provide good support simultaneously, have again corresponding selenium api. well to implement to select simultaneously.
Embodiment 3
The present embodiment provides a kind of multichannel webpage control locating device, and can realize the localization method of above-described embodiment 1 and 2, this device as shown in Figure 7, comprising:
Extraction module, extract effective attribute of target widget to set A, in current DOM structure, search label and community set and described effective attribute to the identical control of set A, if found, and the control found and target widget are fraternal control, then adopt the position of index information indicating target control in fraternal control, and using this index information and described effective attribute to the locator data of set A as target widget; If found, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and described effective attribute to the locator data of set A as target widget; If do not found, then using described effective attribute to the locator data of set A as target widget;
Wherein, effective attribute is at least comprising tag types, the label of control, property value in set A to sequence.
Preferably, said extracted module, one or more information following can also be extracted from target widget, and the information of extraction is added in the locator data of target widget:
Cascading Style Sheet (CSS) selector switch information, active path information, page area figure information.
Wherein, CSS selector switch, xpath are often applied to searching of target widget.Therefore, the locator data of target widget contains CSS selector switch information, active path information, just can provide an alternative approach when self-adjusting location algorithm can not find target widget, ensures the stability of control location.
And the page area figure information of target widget also can add in locator data, this pictorial information not only may be used for control location, can also be used for the monitoring of control outward appearance.But do not have it not affect control location to a certain extent, so be optional additional data yet yet.
Locating module, the locator data according to the target widget of extraction module extraction positions target widget.
In the present embodiment, above-mentioned locating module comprises again:
Judge module, judges whether include described index information in described locator data;
First processing unit, when having described index information in locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises the attribute successively decreased and searches thread.
Alternatively, the first processing unit can also set up one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Second processing unit, when not including described index information in locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises partial circulating and searches thread and the attribute that increases progressively searches thread.
Alternatively, the second processing unit can also set up one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
Consider that the appearance style of control changes, the problem of potential impact location may be there is.Therefore, said apparatus can also increase a monitoring module, for the monitoring of control outward appearance, when comprising page area figure information in locator data, when occurring to change according to the outward appearance of this page area figure INFORMATION DISCOVERY target widget, the control outward appearance upgraded is analyzed and fed back to user.
As can be seen from above-described embodiment, technical scheme tool has the following advantages:
Stability is high: according to above-mentioned lookup algorithm, can find out, even if there is increase and decrease to a certain degree at the attribute of target widget, upgrades or deletes.As long as other attributes of this target widget are still effective, then just can successfully locate this control.Meanwhile, even if the current attribute of target widget lost efficacy or by other element influences, as long as its outward appearance does not change, also can recognize this control by areal map.
Efficiency is high: the search procedure in preferred version is because there is multi-channel approach to carry out simultaneously, and centre with the path returned results the soonest responsively, and therefore location efficiency is high.Wherein, the fastest response time is 1(Short-circuit, CSS), the locator data of the slowest speed to be N(N be target widget comprises the number of information), be N when increasing progressively the exhaustive complete all information of the finger that successively decreases.After taking parallel multithread, location cost is 1 to N, identical with accurate formula attributes match efficiency.
The all or part of step that one of ordinary skill in the art will appreciate that in said method is carried out instruction related hardware by program and is completed, and described program can be stored in computer-readable recording medium, as ROM (read-only memory), disk or CD etc.Alternatively, all or part of step of above-described embodiment also can use one or more integrated circuit to realize.Correspondingly, each module/unit in above-described embodiment can adopt the form of hardware to realize, and the form of software function module also can be adopted to realize.The application is not restricted to the combination of the hardware and software of any particular form.
The above, be only preferred embodiments of the present invention, be not intended to limit protection scope of the present invention.Within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (16)

1. a multichannel webpage control localization method, it is characterized in that, the method comprises:
Extract effective attribute of target widget to set A;
In current file object model (DOM) structure, search label and community set and described effective attribute to the identical control of set A;
If found, and the control found and target widget are fraternal control, then adopt the position of index information indicating target control in fraternal control, and using this index information and described effective attribute to the locator data of set A as target widget;
If found, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and described effective attribute to the locator data of set A as target widget;
If do not found, then using described effective attribute to the locator data of set A as target widget;
Locator data according to described target widget positions target widget.
2. the method for claim 1, is characterized in that, described effective attribute is at least comprising tag types, the label of control, property value in set A to sequence.
3. method as claimed in claim 1 or 2, it is characterized in that, the method also comprises:
Also from described target widget, extract one or more information following, and the information of extraction added in the locator data of described target widget:
Cascading Style Sheet (CSS) selector switch information, active path information, page area figure information.
4. method as claimed in claim 3, it is characterized in that, the locator data according to described target widget comprises the process that target widget positions:
When judging to include described index information in described locator data, set up multiple thread of searching and search described target widget simultaneously, the thread of searching set up at least comprises the attribute successively decreased and searches thread.
5. method as claimed in claim 4, is characterized in that, when including described index information in described locator data, the thread of searching of foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
6. method as claimed in claim 3, it is characterized in that, the locator data according to described target widget comprises the process that target widget positions:
When judging not include described index information in described locator data, set up multiple thread of searching and search described target widget simultaneously, the thread of searching set up at least comprises partial circulating and searches thread and the attribute that increases progressively searches thread.
7. method as claimed in claim 6, is characterized in that, when not including described index information in described locator data, the thread of searching of foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
8. method as claimed in claim 3, it is characterized in that, the method also comprises:
Monitor the control outward appearance of described target widget, when the control outward appearance of described target widget changes, the control outward appearance upgraded is analyzed and fed back to user.
9. a multichannel webpage control locating device, is characterized in that, this device comprises:
Extraction module, extract effective attribute of target widget to set A, in current file object model (DOM) structure, search label and community set and described effective attribute to the identical control of set A, if found, and the control found and target widget are fraternal control, then adopt the position of index information indicating target control in fraternal control, and using this index information and described effective attribute to the locator data of set A as target widget; If found, but the control found and the non-fraternal control of target widget, then extract the locator data of the parent control of target widget, and using the locator data of the parent control of target widget extracted and described effective attribute to the locator data of set A as target widget; If do not found, then using described effective attribute to the locator data of set A as target widget;
Locating module, the locator data according to described target widget positions target widget.
10. device as claimed in claim 9, is characterized in that, described effective attribute is at least comprising tag types, the label of control, property value in set A to sequence.
11. devices as described in claim 9 or 10, is characterized in that,
Described extraction module, also extracts one or more information following, and the information of extraction is added in the locator data of described target widget from described target widget:
Cascading Style Sheet (CSS) selector switch information, active path information, page area figure information.
12. devices as claimed in claim 11, it is characterized in that, described locating module comprises:
Judge module, judges whether include described index information in described locator data;
First processing unit, when having described index information in described locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises the attribute successively decreased and searches thread.
13. devices as claimed in claim 12, is characterized in that, the thread of searching of described first processing unit foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
14. devices as claimed in claim 12, it is characterized in that, described locating module also comprises:
Second processing unit, when not including described index information in described locator data, sets up multiple thread of searching and searches described target widget simultaneously, and the thread of searching set up at least comprises partial circulating and searches thread and the attribute that increases progressively searches thread.
15. devices as claimed in claim 14, is characterized in that, the thread of searching of described second processing unit foundation also comprises one or more threads following:
CSS searches thread, figure script searches thread, active path information attribute searches thread.
16. devices as claimed in claim 11, it is characterized in that, this device also comprises:
Monitoring module, monitors the control outward appearance of described target widget, when the control outward appearance of described target widget changes, analyzes the control outward appearance upgraded and feeds back to user.
CN201310590812.1A 2013-11-20 2013-11-20 A kind of multichannel webpage control localization method and device Active CN104657377B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310590812.1A CN104657377B (en) 2013-11-20 2013-11-20 A kind of multichannel webpage control localization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310590812.1A CN104657377B (en) 2013-11-20 2013-11-20 A kind of multichannel webpage control localization method and device

Publications (2)

Publication Number Publication Date
CN104657377A true CN104657377A (en) 2015-05-27
CN104657377B CN104657377B (en) 2018-04-03

Family

ID=53248523

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310590812.1A Active CN104657377B (en) 2013-11-20 2013-11-20 A kind of multichannel webpage control localization method and device

Country Status (1)

Country Link
CN (1) CN104657377B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105320603A (en) * 2015-12-04 2016-02-10 上海斐讯数据通信技术有限公司 Locating system and method for browser page elements and automatic testing method thereof
CN106503124A (en) * 2016-10-19 2017-03-15 北京小米移动软件有限公司 The method and apparatus of multimedia file positioning in the page
CN107015907A (en) * 2017-03-15 2017-08-04 中国地质大学(武汉) A kind of system and method for automatic accurate positioning webpage element
CN107220066A (en) * 2017-06-28 2017-09-29 北京金山安全软件有限公司 Method and device for releasing application software in application store
CN107402756A (en) * 2017-07-07 2017-11-28 北京小米移动软件有限公司 For drawing the method, apparatus and terminal of the page
CN107515821A (en) * 2016-06-17 2017-12-26 百度在线网络技术(北京)有限公司 Components testing method and apparatus
CN108804181A (en) * 2018-05-28 2018-11-13 北京小米移动软件有限公司 Control content acquisition method, device and storage medium
CN109977267A (en) * 2019-02-02 2019-07-05 广州云测信息技术有限公司 The method and apparatus for determining the path XPath
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)
CN111221612A (en) * 2020-01-03 2020-06-02 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN111368241A (en) * 2020-03-05 2020-07-03 苏州数字力量教育科技有限公司 Webpage element identification method based on XPath
CN113971058A (en) * 2020-07-22 2022-01-25 北京奇虎科技有限公司 Control positioning method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6571253B1 (en) * 2000-04-28 2003-05-27 International Business Machines Corporation Hierarchical view of data binding between display elements that are organized in a hierarchical structure to a data store that is also organized in a hierarchical structure
CN102622395A (en) * 2011-12-20 2012-08-01 深信服网络科技(深圳)有限公司 Method, server and client for assisting in accessing to webpage by application virtualization
CN102637128A (en) * 2012-03-14 2012-08-15 北京神州数码思特奇信息技术股份有限公司 Method for generating selection controls of general levels
CN103177115A (en) * 2013-04-03 2013-06-26 北京奇虎科技有限公司 Method and device of extracting page link of webpage

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6571253B1 (en) * 2000-04-28 2003-05-27 International Business Machines Corporation Hierarchical view of data binding between display elements that are organized in a hierarchical structure to a data store that is also organized in a hierarchical structure
CN102622395A (en) * 2011-12-20 2012-08-01 深信服网络科技(深圳)有限公司 Method, server and client for assisting in accessing to webpage by application virtualization
CN102637128A (en) * 2012-03-14 2012-08-15 北京神州数码思特奇信息技术股份有限公司 Method for generating selection controls of general levels
CN103177115A (en) * 2013-04-03 2013-06-26 北京奇虎科技有限公司 Method and device of extracting page link of webpage

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105320603B (en) * 2015-12-04 2018-04-06 上海斐讯数据通信技术有限公司 The alignment system and method and its automated testing method of browser page element
CN105320603A (en) * 2015-12-04 2016-02-10 上海斐讯数据通信技术有限公司 Locating system and method for browser page elements and automatic testing method thereof
CN107515821A (en) * 2016-06-17 2017-12-26 百度在线网络技术(北京)有限公司 Components testing method and apparatus
CN106503124A (en) * 2016-10-19 2017-03-15 北京小米移动软件有限公司 The method and apparatus of multimedia file positioning in the page
CN106503124B (en) * 2016-10-19 2019-08-30 北京小米移动软件有限公司 The method and apparatus that multimedia file positions in the page
CN107015907A (en) * 2017-03-15 2017-08-04 中国地质大学(武汉) A kind of system and method for automatic accurate positioning webpage element
CN107220066A (en) * 2017-06-28 2017-09-29 北京金山安全软件有限公司 Method and device for releasing application software in application store
CN107220066B (en) * 2017-06-28 2020-08-28 北京金山安全软件有限公司 Method and device for releasing application software in application store
CN107402756B (en) * 2017-07-07 2020-07-31 北京小米移动软件有限公司 Method, device and terminal for drawing page
CN107402756A (en) * 2017-07-07 2017-11-28 北京小米移动软件有限公司 For drawing the method, apparatus and terminal of the page
CN108804181A (en) * 2018-05-28 2018-11-13 北京小米移动软件有限公司 Control content acquisition method, device and storage medium
CN108804181B (en) * 2018-05-28 2021-09-28 北京小米移动软件有限公司 Control content obtaining method and device and storage medium
CN109977267B (en) * 2019-02-02 2021-09-03 北京云测信息技术有限公司 Method and device for determining XPath path
CN109977267A (en) * 2019-02-02 2019-07-05 广州云测信息技术有限公司 The method and apparatus for determining the path XPath
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)
CN111221612A (en) * 2020-01-03 2020-06-02 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN111221612B (en) * 2020-01-03 2023-08-29 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN111368241A (en) * 2020-03-05 2020-07-03 苏州数字力量教育科技有限公司 Webpage element identification method based on XPath
CN111368241B (en) * 2020-03-05 2023-05-30 苏州数字力量教育科技有限公司 Webpage element identification method based on XPath
CN113971058A (en) * 2020-07-22 2022-01-25 北京奇虎科技有限公司 Control positioning method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN104657377B (en) 2018-04-03

Similar Documents

Publication Publication Date Title
CN104657377A (en) Multi-channel webpage control positioning method and device
US9424167B2 (en) Automated testing of an application system
CN101464905B (en) Web page information extraction system and method
US8667015B2 (en) Data extraction method, computer program product and system
US9207933B2 (en) Identifying authors of changes between multiple versions of a file
CN113391871B (en) RPA element intelligent fusion picking method and system
US9418315B1 (en) Systems, methods, and computer readable media for extracting data from portable document format (PDF) files
US9098479B2 (en) Methods and apparatus for improved navigation among controlled terms in one or more user documents
KR20210100600A (en) software testing
US9817875B2 (en) Methods and systems for automated data characterization and extraction
CN102831121A (en) Method and system for extracting webpage information
US11256912B2 (en) Electronic form identification using spatial information
CN102804147A (en) Code inspection executing system for performing a code inspection of ABAP source codes
CN103942212A (en) User interface character detecting method and device
CN109344355B (en) Automatic regression detection and block matching self-adaption method and device for webpage change
CN103019925A (en) Selector acquisition method and device
US10474887B2 (en) Identifying a layout error
US8381164B2 (en) Method and system of intelligent interactive graphics electrical plug map to analyze text and distances between electrical contacts and physical layout file builder
US20140301644A1 (en) Extracting Reading Order Text and Semantic Entities
CN111368241B (en) Webpage element identification method based on XPath
Parameswaran et al. Optimal schemes for robust web extraction
CN104516813A (en) Method and device for selecting testing node of web page
CN105426305A (en) Control attribute analysis system and method
CN112328488A (en) Control object identification method for UI (user interface) automatic test
CN111813443A (en) Method and tool for automatically filling code sample by JavaFX

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240208

Address after: # 01-21, Lai Zan Da Building 1, 51 Belarusian Road, Singapore

Patentee after: Alibaba Singapore Holdings Ltd.

Country or region after: Singapore

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: ALIBABA GROUP HOLDING Ltd.

Country or region before: United Kingdom

TR01 Transfer of patent right