CN108345485B - Identification method and device for interface view - Google Patents

Identification method and device for interface view Download PDF

Info

Publication number
CN108345485B
CN108345485B CN201810090424.XA CN201810090424A CN108345485B CN 108345485 B CN108345485 B CN 108345485B CN 201810090424 A CN201810090424 A CN 201810090424A CN 108345485 B CN108345485 B CN 108345485B
Authority
CN
China
Prior art keywords
view
index
type
views
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810090424.XA
Other languages
Chinese (zh)
Other versions
CN108345485A (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.)
Koubei Shanghai Information Technology Co Ltd
Original Assignee
Koubei Shanghai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Koubei Shanghai Information Technology Co Ltd filed Critical Koubei Shanghai Information Technology Co Ltd
Priority to CN201810090424.XA priority Critical patent/CN108345485B/en
Publication of CN108345485A publication Critical patent/CN108345485A/en
Application granted granted Critical
Publication of CN108345485B publication Critical patent/CN108345485B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Abstract

The application discloses an identification method for an interface view, which comprises the following steps: acquiring a view tree; traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type; and determining the view identification of the root view, and determining the view identification of each level of view on the view path step by step from the direct sub-view of the root view on the basis of the view identification of the root view and the view indexes and view types of each level of view on the view path so as to solve the problem that interface views cannot be uniquely identified on different terminals based on the same mobile operating system.

Description

Identification method and device for interface view
Technical Field
The application relates to the technical field of computers, in particular to an identification method for an interface view. The application also relates to an identification device for the interface view. The application also relates to a positioning method and device for the interface view.
Background
Currently, mobile operating systems and mobile terminals running mobile application products are increasingly diversified, for example: for a mobile operating system iOS, mobile terminals have various models and different screen sizes such as iPhone 6, iPhone X, etc., and a multi-terminal compatibility test is also required for a mobile application product APP of the same operating system. The method has the advantages that the automatic test is adopted to synchronize the actions of the mobile terminals, generate action instructions and replay the actions, a test mode that testers respectively operate the mobile terminals is replaced, and the accuracy of the action synchronization of different terminals is very important, for example, when a series of actions such as clicking actions and sliding actions are synchronized between the two iOS mobile terminals, generally, a view generated by the actions is found firstly, and then a corresponding view is found at the other terminal, so that the action sources are ensured to be the same. How to uniquely identify a view is a key in determining the same view on different terminals.
The existing view identification scheme generally gives a view identification according to the relationship of parent and child nodes of a view tree, and has the problem that an interface view cannot be uniquely identified, on one hand, the view identification is a group of views which are possibly identified and cannot be accurately positioned to one view, such as a reusable view, and on the other hand, when the addition, removal and position change of other interface views exist, the view identification can also be changed, so that the problem that the interface view cannot be uniquely identified even on different terminals based on the same mobile operating system exists.
Disclosure of Invention
The application provides an identification method for an interface view, which aims to solve the problem that the interface view cannot be uniquely identified on different terminals based on the same mobile operating system.
The present application additionally provides an identification device for an interface view.
The application also provides a positioning method for the interface view.
The application also provides a positioning device for the interface view.
The application provides an identification method for an interface view, which comprises the following steps:
acquiring a view tree;
traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type;
and determining the view identification of the root view, and determining the view identification of each level of view on the view path from the direct sub-view of the root view step by step based on the view identification of the root view and the view indexes and view types of the views on each level of the view path.
Optionally, the view type includes any one of the following types:
regular view, global multiplex view, table class view.
Optionally, the determining the view index of each view according to the view type by using the corresponding index rule includes:
judging the view type of the view as a conventional view;
the view index is maintained according to the order of addition of the views.
Optionally, the maintaining of the view index according to the adding order of the view includes the following processing:
monitoring addition, removal and view level change events of each view in the view tree;
when the view is added, setting the view index of the view according to the number of the child views in the parent view of the view.
Optionally, the maintaining of the view index according to the adding order of the view further includes the following processing:
monitoring addition, removal and view level change events of each view in the view tree;
when it is monitored that the view is removed from its parent view, the view identification of the view and all its child views is reset.
Optionally, the maintaining of the view index according to the adding order of the view further includes the following processing:
and when the view is added to the parent view, dynamically generating the view indexes according to the adding sequence.
Optionally, the determining the view index of each view according to the view type by using the corresponding index rule includes:
judging the view type of the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
Optionally, the predetermined sorting priority is sorted from high to low according to the following priorities: view Y axis location, view X axis location, whether the view is system private type, whether the view is hidden.
Optionally, the determining the view index of each view according to the view type by using the corresponding index rule includes:
judging the view type of the view as a table type view;
and determining the view index according to the block position of the view.
Optionally, the block position is identified by a section sequence number and a row sequence number.
Optionally, the conventional view at least includes any one of the following views: tab view, root view of view tree, button view.
Optionally, the global multiplexing view at least includes any one of the following views: navigation bar view, layout container view.
Optionally, the table class view at least includes any one of the following views: table view, collection view.
Optionally, the traversing from the root view to the target view of the view tree includes: traversal according to depth first or traversal according to breadth first.
Optionally, the step-by-step determining the view identifier of each level of view on the view path includes: and generating the view identification of the target view according to the parent view identification of the target view, the view index of the target view and the view type information of the target view.
The application also provides a positioning method for the interface view, which comprises the following steps:
according to a preset rule, detaching a view index and a view type of a target view from a given view identifier and view indexes and view types of all levels of parent views of the target view, and forming a first view path by using child nodes described by the view indexes and the view types according to a parent-child view hierarchical relationship;
traversing a second view tree from the root view, generating a view index and a view type for the traversed current view according to the predetermined rule, and positioning an information consistent child node in the first view path according to the view index and the view type;
judging whether an information consistency child node is positioned or not and whether the child node is the last node in the first view path or not; if yes, the current view is the positioned target view.
Optionally, the predetermined rule refers to a rule for constructing a view identifier, and the view identifier constructed by the rule at least includes the following components:
parent view identification, view index, view type information.
Optionally, the generating method of the view index includes: and generating a view index by adopting a corresponding index rule according to the view type.
Optionally, the generating a view index by using a corresponding index rule according to the view type includes:
judging the view to be a conventional view;
the view index is maintained according to the order of addition of the views.
Optionally, the generating a view index by using a corresponding index rule according to the view type includes:
judging the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
Optionally, the generating a view index by using a corresponding index rule according to the view type includes:
judging the view as a table class view;
and determining the view index according to the block position of the view.
Optionally, the determining whether the information consistent child node is located includes the following steps:
traversing breadth-first a sub-view of a current view of the second view tree under the current view.
Optionally, the determining whether the information consistent child node is located includes the following steps:
if the information consistency child node is not positioned, judging that the view types are inconsistent, and then carrying out fuzzy positioning.
Optionally, the fuzzy positioning includes the following processing: and judging all the sub-views in the current view as alternative views according with the view type information, and positioning the alternative views to the target view in the first view path according to the view indexes and the view types of the alternative views.
Optionally, traversing the second view tree from the root view includes: traversal is prioritized by breadth.
The present application further provides an identification device for an interface view, comprising:
the view tree generating unit is used for acquiring a view tree;
the view index generating unit is used for traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type;
and the view identifier generating unit is used for determining the view identifier of the root view, and determining the view identifiers of the views at all levels on the view path step by step from the direct sub-view of the root view based on the view identifier of the root view and the view indexes and view types of the views at all levels on the view path.
The present application further provides a positioning device for an interface view, comprising:
a first view path generating unit, configured to tear down, according to a predetermined rule, a view index and a view type of a target view and a view index and a view type of each level of parent views of the target view from a given view identifier, and compose a first view path from child nodes described by the view index and the view type according to a hierarchical relationship between parent views and child views;
and the positioning unit is used for traversing the second view tree from the root view, generating a view index and a view type for the traversed current view according to the predetermined rule, and positioning the information consistent child node in the first view path according to the view index and the view type.
The target view determining unit is used for judging whether an information consistency child node is positioned or not and whether the child node is the last node in the first view path or not; if yes, the current view is the positioned target view.
Compared with the prior art, the method has the following advantages:
according to the identification method and device for the interface view and the electronic equipment, the view tree is obtained; traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type; determining the view identification of the root view, determining the view identification of each level of view on the view path step by step from the direct child view of the root view based on the view identification of the root view and the view index and the view type of each level of view on the view path, and uniquely and stably identifying the interface view based on the view index uniqueness of each view in the parent view of each view and simultaneously combining the description information of each view type and the parent view identification, thereby solving the problem that the interface view cannot be uniquely identified on different terminals based on the same mobile operating system.
Drawings
FIG. 1 is a process flow diagram of an identification method for an interface view provided by an embodiment of the present application;
fig. 2 is a view identification composition diagram included in an identification method for an interface view according to an embodiment of the present application;
fig. 3 is a schematic view index change diagram when a view is inserted, which is included in the identification method for an interface view according to the embodiment of the present application;
fig. 4 is a view tree diagram corresponding to a view identification sample of the identification method for an interface view according to the embodiment of the present application;
FIG. 5 is a process flow diagram of a positioning method for an interface view according to an embodiment of the present disclosure;
FIG. 6 is a positioning flowchart included in a positioning method for an interface view according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of an identification device for an interface view provided by an embodiment of the present application;
fig. 8 is a schematic view of a positioning device for an interface view according to an embodiment of the present application.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The application provides an identification method for an interface view. The application also relates to an identification device for the interface view. The application also provides a positioning method for the interface view. The application also relates to a positioning device for the interface view. Details are described in the following examples one by one.
The embodiment of the application provides an identification method for an interface view.
Embodiments of the identification method for an interface view provided by the present application are described below with reference to fig. 1 to 4. FIG. 1 is a process flow diagram of an identification method for an interface view according to an embodiment of the present disclosure; fig. 2 is a view identification composition diagram included in an identification method for an interface view according to an embodiment of the present application; fig. 3 is a schematic view index change diagram when a view is inserted, which is included in the identification method for an interface view according to the embodiment of the present application; fig. 4 is a view tree diagram corresponding to a view identification sample of the identification method for an interface view according to the embodiment of the present application.
The identification method for the interface view provided by the embodiment of the application is mainly applied to the APP automatic test of a mobile application product, and is generally deployed in a mobile terminal such as a mobile phone, but is not limited to a mobile terminal device and an automatic test scenario, and for example, can also be applied to an interface operation playback scenario. Taking a mobile phone as an example, when a series of actions (such as clicking actions and sliding actions) are synchronized between two mobile phones, currently, the coordinate positions of the actions within the screen range are generally synchronized, but in this way, when the sizes of the screens of the mobile phones are different, errors occur in the positions of action synchronization. In order to solve the problem, a view generating the action needs to be found first, and then a corresponding view is also found on the other mobile phone, so that the synchronous action sources are ensured to be the same, and the action synchronization accuracy is improved. In order to find the same view on two different mobile phones, a method for uniquely identifying and positioning a client view is required, and the identification method for the interface view provided by the embodiment of the application can be applied to the action synchronization, the action instruction generation and the action replay of multiple devices based on the same mobile operating system, so that the efficiency of compatibility testing and the accuracy of automatic testing are improved, for example, the method is used for the action synchronization of the same mobile application among different iOS terminals and the action synchronization of the same mobile application among different Android terminals. The interface views refer to views such as buttons, pictures and texts which can be seen by a user on a client page, the interface views to be identified in different scenes are different, for example, the interface views to be tested in an automated multi-terminal compatible test scene at least comprise buttons, menus, lists and the like, the actions of the interface views are tracked and analyzed, firstly, the interface views need to be identified, namely, an ID is set for a target view, different IDs of the different interface views are ensured, the overall situation is unique and stable, the identifications of the same interface views of the same type of mobile application product client on different terminals are kept consistent, so that uniform and accurate analysis is facilitated, and the interface views to be identified are called target views or positioning views; and setting the ID of the interface view as the view identifier.
The identification method for the interface view, provided by the embodiment of the application, can generate the globally unique and stable view identification for the interface view with the same visual effect or interaction effect in the same mobile application based on different terminals of the same mobile operating system. By setting the view identifier for the interface view on one terminal, the view identifier is globally unique and stable, and can be accurately positioned to the same view on other different terminals based on the same mobile operating system according to the view identifier, so that the action synchronization of different terminals is further realized. For example, the interface view is a button in the mobile phone public praise application interface for guiding the user to turn on how hungry to take out, the view identification of a button in the mobile phone public praise application client for guiding the user to turn on how hungry to take out is a, the view identification of a button in the mobile phone public praise interface for guiding the user to turn on how hungry to take out is also a instead of B, and the view identification is kept as a all the time during the repeated testing.
The identification method for the interface view shown in fig. 1 comprises the following steps: step S101 to step S103.
Step S101, acquiring a view tree.
The purpose of this step is to obtain a view tree containing the target view to be identified.
The view tree acquisition includes a view tree generated by acquiring partial views of the page or a view tree generated by acquiring all views of the page.
The interface views contained in the mobile application page are intuitively generalized into a tree structure called a view tree. The view tree embodies interface view information of the mobile application, and records the layout and hierarchical relationship of each interface view of the current page, wherein each interface view has only one parent view and zero or more child views, the tree has an abstract root node, the view corresponding to the root node is the root view, for example, for an iOS system, the view can be a UIView view, the direct child view of the root view is each window UIWindow of the mobile application, and the child view of each window can be a button, a navigation, a table and the like.
Specifically, in the embodiments provided by the present application, a page view tree of a mobile application product is generated from a runtime of the mobile application product, a mobile application page may include thousands of interface views, and a view tree of some parts of the view tree or the entire page is generated by setting a scope or filtering as needed. The set scope refers to a scope defining a view from a root node of the view tree, e.g., intended to contain only the immediate children of the current window or control, or all descendants of a certain window or control. The screening refers to defining interface view types included in the view tree or applying other screening conditions to screen the interface views included in the view tree, for example, only enabled controls are included in a control view.
And S102, traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type.
The purpose of this step is to determine the target view and its parent views at each level, the view indices in all the child view sets of the respective parent views.
In the embodiment of the present application, traversing from the root view of the view tree to the target view to obtain the view path of the target view includes: traversal according to depth first or traversal according to breadth first. Preferably, it is an extent traversal. In the embodiment of the present application, respective view indexes are determined according to view types to which views (including the target view and its parent views at different levels) on the view path belong, and the view indexes of different view types are maintained according to different index rules, so-called maintaining the view indexes includes allocating the view indexes to the views. Wherein the view type includes any one of the following types: regular view, global multiplex view, table class view. Taking the iOS system as an example, the conventional view at least includes any one of the following views: a tab view, a root view of a view tree, a button view, e.g., UILabel, UIView, UIButton; the global multiplexing view at least comprises any one of the following views: a navigation bar view and a layout container view; for example, UINavigationBar, UILayoutContainerView; the table class view at least comprises any one of the following views: table view, collection view, e.g., UITableView, UICollectionView. The view type division is mainly based on whether the sub-views are stable and whether the views are reusable, and whether the sub-views are stable refers to whether a large amount of addition and/or removal of the sub-views of one view occurs in one operation. For example, in the navigation bar view, when the page is switched, some views of the system are added and removed in a large amount, so that the sub-view array of the navigation bar view is very unstable. Whether the views are reusable or not refers to recycling and multiplexing of the views, the views cannot be seen after being moved out of an interface but can enter a cache pool (or a multiplexing pool), when a new view needing to be displayed exists, an available view is firstly taken from the cache pool, and the view is created again after the view fails to be obtained. For example, the Cell of the iOS table view UITableView may be multiplexed during the sliding process, but the index path indexPath of the Cell is unique, i.e., the combination value of section and row is unique.
Specifically, in the embodiment of the present application, according to the view type to which the target view and its parent views at different levels belong, the view index of the target view and its parent views at different levels is determined by using a corresponding index rule, and before this step, the view type to which the target view and its parent views at different levels belong needs to be determined, and the respective view index is determined, and any one of the following processing methods (one) to (three) is adopted:
judging the view type of the view as a conventional view; the view index is maintained according to the order of addition of the views.
In the embodiment of the present application, for a conventional view, a unique index is assigned to the view according to the adding order of the view, for example, a unique position index is assigned to the view according to the adding order of the view in its parent view, instead of adopting the position of the view in the view array (which represents the set of all child views under one parent view) of all child views of the view in the parent view, because the position order in the view array is unstable, and can be changed by the influence of other views. While the position index can be kept unchanged by assigning position subscripts in the order of addition, see fig. 3, which shows the change of view subscripts during a new view addition, wherein the grey-bottom circle represents the interface view and the unfilled circle represents the interface view to be added, and as can be seen from fig. 3, view 7 is added to view2 at the second position of the sub-view of view2, but with view subscript v 3; view 5, after view 7 is added, is in the third position of the sub-view of view2, but its view index is still v2, and there is no change due to the addition of view 7, and a stable index remains.
Specifically, the maintaining of the view index according to the adding order of the view includes the following processing:
monitoring addition, removal and view level change events of each view in the view tree;
when the view is added, setting the view index of the view according to the number of the child views in the parent view of the view.
For example, in the process of running APP, when a certain view is operated (clicked or slid), a view identifier of the view is dynamically generated, and in concrete implementation, a maintenance variable records the number of child views added by a parent view and the subscripts of the corresponding child views, for example, using subviwount and viewIndex, the default number of child views in the view tree is 0, and the default view index is null, when the parent view calls addSubview or insertSubView, the view is added to the parent view, and the child view index is dynamically generated according to an addition order, that is, when a child view is added, the subViewCount is added by 1, and the viewIndex is set to the child view according to the addition order. The subviwcount records all the number of addition operations. When it is monitored that the view is removed from the parent view, the view identifiers of the view and all the child views thereof are reset, and the specific implementation further includes maintenance on the subViewCount of the parent view, that is, the child view count of the parent view is firstly kept unchanged, only the child views of the parent view are completely removed, and when the actual number of the child views is 0, the subViewCount of the parent view is set to 0.
(II) judging the view type of the view as a global multiplexing view; and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
In the embodiment of the application, for the global multiplexing view, the view index is determined by sorting the view according to the position of the view on the interface. Preferably, the predetermined sorting priority is sorted according to the following priority from high to low: view Y axis location, view X axis location, whether the view is system private type, whether the view is hidden. In addition, the sorting can be performed according to other priority orders as long as the position order is guaranteed to be unique.
(III) judging the view type of the view as a table type view; and determining the view index according to the block position of the view. Specifically, the block position is identified by a section sequence number and a row sequence number, that is, a unique subscript is defined for the block position according to the section and the row number where the block is located, and the subscript is used as a view index. The section number is a unique number of a block of the table view, and the row number is a row number under the block of the table view.
Setting the view indexes of the views at different levels on the view path according to the rules described in the above (a) to (b), that is, setting the view indexes of the target view and its parent views at different levels, where each view index, in combination with its view type, can uniquely represent any child view of the parent view in one parent view.
Step S103, determining the view identifier of the root view, and determining the view identifier of each level of view on the view path step by step from the direct sub-view of the root view based on the view identifier of the root view and the view index and the view type of each level of view on the view path.
The purpose of this step is to generate view identifiers of views at different levels according to the view index generated in step S102 and in combination with the view types of the views, where the view identifiers include the view identifier of the target view included on the view path. The view identifier of the target view may be summarized in the form shown in fig. 2, which briefly expresses the components of the view identifier. Because the view indexes generated by each level of view in the view path of the target view in step S102 have uniqueness in all the child views of the parent view thereof, the view identifier formed in the manner described in this step has global uniqueness, and can uniquely represent any one view on the interface, and the view identifier is stable and not easy to change, and thus can be accurately positioned to any one view on the interface according to the view identifier formed in this manner.
In addition, in this embodiment of the application, the step-by-step determining the view identifier of each level of view on the view path includes: the view identifier of the target view is generated according to the parent view identifier of the target view, the view index of the target view, and the view type information of the target view, for example, a separator is used to connect the parent view identifier of the target view, the view index of the target view, and the view type information of the target view as the view identifier, wherein the view type information is description information generated according to the type name description of the target view. For example, the delimiter adopts "-" or "_".
Specific examples are: as shown in fig. 4, a target view VZFStackView2 in the view tree, where an arrow line with a reference number of 1 indicates a path of the target view in the view tree, and components in the view identifier use a "-" connection, a view identifier example generated according to the identification method for an interface view provided by the embodiment of the present application is as follows:
iConsoleWindow-sub[0](UITransitionView)-sub[0](DTBaseView)-sub[2](tableview)-sub[s0_r4](table_cell)-sub[0](UITableViewCellContentView)-sub[0](VZFStackView)-sub[2](VZFStackView)
the description so far is a description of an identification method for an interface view provided by an embodiment of the present application.
Based on the above embodiment of the identification method for the interface view, the present application further provides an embodiment of a positioning method for the interface view.
The following describes a positioning method for an interface view provided in an embodiment of the present application with reference to fig. 5 to 6. Since the present embodiment is based on the above embodiment, the description thereof is brief, and please refer to the relevant part of the above embodiment of the identification method for an interface view.
The positioning method for the interface view provided by the embodiment of the application can perform view positioning according to the known view identifier, is mainly deployed in a mobile terminal, but is not limited to the mobile terminal, and can also be applied to other scenes related to interface view positioning. The view positioning refers to finding views with the same view identifier in a view tree according to the view identifier, wherein path hierarchy information included in the view tree is completely consistent; the view identifier is generated according to a certain rule. For example, clicking 'food' on a public praise application home page of the iOS mobile phone 1, generating a globally unique and stable view identifier according to a certain method for a corresponding interface view, and positioning the same view on the iOS mobile phone 2 according to the view identifier, thereby further realizing the action synchronization of different terminals.
The positioning method for the interface view shown in fig. 5 includes: steps S501 to S503.
Step S501, a view index and a view type of a target view and a view index and a view type of each level of parent views of the target view are separated from a given view identifier according to a preset rule, and child nodes described by the view indexes and the view types form a first view path according to a parent-child view hierarchical relationship.
The purpose of this step is to separate the target view and its parent views of each level from the known view identifier according to the child node format, where the child node format is the node described by the view index and the view type, and these child nodes form the view path according to the hierarchical relationship of the parent and child views, so as to be used as the comparison standard when positioning the target view in the view tree.
In the embodiment of the present application, the predetermined rule refers to a rule for constructing a view identifier, and specifically refers to a rule for generating a view identifier for a view in a view tree, where the view identifier formed by the rule at least includes the following components: parent view identification, view index, view type information. The generation method of the view index comprises the following steps: and generating a view index by adopting a corresponding index rule according to the view type, and ensuring that the view index and the type description information can be uniquely positioned to any child view in the parent view of the view index. Views can be divided into the following three types: regular view, global multiplex view, table class view. Taking the iOS system as an example, the conventional view at least includes any one of the following views: a tab view, a root view of a view tree, a button view, e.g., UILabel, UIView, UIButton; the global multiplexing view at least comprises any one of the following views: navigation bar views, layout container views, which typically show a large number of additions and/or removals of their child views in one operation; for example, UINavigationBar, UILayoutContainerView; the table class view at least comprises any one of the following views: the method comprises the steps of table views and collection views, wherein the views can be generally recycled and reused, the views cannot be seen after being moved out of an interface, but can enter a cache pool (or a reuse pool), when a new view needing to be displayed exists, an available view is firstly taken from the cache pool, and the view is not obtained and then is created again, for example, UITableView and UICollectionView.
In the embodiment of the application, if the view is a conventional view, the view index of the view is maintained according to the adding sequence of the view. For example, rather than taking the position of the view in the view array of all the children views of its parent view (which represents the set of all the children views under one parent view), the view is assigned a unique position index in the order of its parent view's addition, which can change due to the influence of other views because the position order in the view array is unstable. And if the view is the global multiplexing view, determining the view index according to the position sorting of the view on the interface and the preset sorting priority. Preferably, the predetermined sorting priority is sorted according to the following priority from high to low: view Y axis location, view X axis location, whether the view is system private type, whether the view is hidden. In addition, the sorting can be performed according to other priority orders as long as the position order is guaranteed to be unique. If the view is a table class view, the view index is determined according to the position of the block where the view is located, for example, the position is identified by using a section sequence number and a row sequence number of the table class view, that is, a unique index is defined according to the section number and the line number of the section (partition) where the block is located, and the position information is expressed by using a format such as s0_ r 4.
Since the view identifier composed in the above manner is globally unique in a mobile application, it is possible to globally uniquely locate a view to the view tree by the view identifier.
Step S502, traversing the second view tree from the root view, generating a view index and a view type for the traversed current view according to the predetermined rule, and positioning an information consistent child node in the first view path according to the view index and the view type.
The purpose of this step is to locate from the second view tree to the interface view consistent with the given view identification.
In this embodiment of the application, preferably, traversing the second view tree from the root view includes: and rapidly positioning the view with path hierarchy information and indexes and type information completely consistent with the given view identification from the second view tree according to breadth-first traversal. In addition, in the process of traversing the second view tree, for the traversed current view, firstly generating a view index and a view type for the current view according to the preset rule (the rule is the same as the rule for generating the given view identifier), and then positioning an information consistent child node in the first view path according to the view index and the view type; if the child node with consistent information is positioned, traversing the child view of the current view under the current view of the second view tree in a breadth-first mode until the last node of the first view path is compared, namely positioning the target view in the second view tree; if the information consistency child node is not located, judging that the view types are inconsistent, then carrying out fuzzy location, and specifically carrying out the following processing: and judging all the sub-views in the current view as alternative views according with the view type information, and positioning the alternative views to the target view in the first view path according to the view indexes and the view types of the alternative views. In addition, in the embodiment of the present application, it is not necessary to compare all view information of each node in the second view tree and the first view path, and after a certain traversed current view is matched, the current view may be searched from the current view to a next generation view, that is, the view tree traversal according to a certain condition is performed.
Step S503, judging whether an information consistency child node is positioned and whether the child node is the last node in the first view path; if yes, the current view is the positioned target view.
The purpose of this step is to determine whether the last node in the first view path is compared with the current view of the traversed second view tree, and to precisely locate the target view.
Specific examples are as follows: FIG. 6 shows a process for uniquely locating a view in a view tree based on a view identification. Firstly, splitting a view identifier into sub-views; traversing the view tree from the root view of the view tree to be positioned according to the breadth-first traversal rule, and searching sub-views with consistent information from the split sub-views according to the view index and the view type maintained according to the index rule; if finding the child view with consistent information, continuously traversing the breadth of the child view on the current view; and if the view types are not consistent, searching all the sub-views under the current view, taking the sub-views which accord with the view types as alternative views, and continuously and accurately searching the alternative views. And traversing to the last view of the split child views, and positioning to the corresponding target view.
The client view positioning method provided by the embodiment of the application can be applied to the action synchronization of multiple devices, the generation of action instructions and the action replay, and the efficiency of compatibility testing and the accuracy of automatic testing are improved.
Corresponding to the embodiment of the identification method for the interface view, the application also provides an identification device for the interface view.
Referring to fig. 7, a schematic diagram of an identification device for an interface view is shown according to the present application. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple, and the relevant portions only need to refer to the corresponding description of the method embodiment. The device embodiments described below are merely illustrative.
The application provides an identification device for an interface view, comprising:
a view tree generating unit 701 configured to acquire a view tree;
a view index generating unit 702, configured to traverse from a root view of the view tree to a target view, obtain a view path of the target view, determine a view type to which each view on the view path belongs, and determine, according to the view type, a view index of each view by using a corresponding index rule;
a view identifier generating unit 703, configured to determine a view identifier of the root view, and based on the view identifier of the root view and the view index and the view type of each level of view on the view path, determine, step by step, the view identifier of each level of view on the view path starting from a direct child view of the root view.
Optionally, the view type includes any one of the following types:
regular view, global multiplex view, table class view.
Optionally, the view index generating unit 702 includes a conventional view index determining subunit, and is configured to perform the following processing:
judging the view type of the view as a conventional view;
the view index is maintained according to the order of addition of the views.
Optionally, the conventional view index determining subunit includes an adding subunit, configured to perform the following processing:
monitoring addition, removal and view level change events of each view in the view tree;
when the view is added, setting the view index of the view according to the number of the child views in the parent view of the view.
Optionally, the conventional view index determining subunit includes a removing subunit, configured to perform the following processing:
monitoring addition, removal and view level change events of each view in the view tree;
when it is monitored that the view is removed from its parent view, the view identification of the view and all its child views is reset.
Optionally, the conventional view index determining subunit is further configured to perform the following processing:
and when the view is added to the parent view, dynamically generating the view indexes according to the adding sequence.
Optionally, the view index generating unit 702 includes a global multiplexing view index determining subunit, and is configured to perform the following processing:
judging the view type of the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
Optionally, the predetermined sorting priority is sorted from high to low according to the following priorities: view Y axis location, view X axis location, whether the view is system private type, whether the view is hidden.
Optionally, the view index generating unit 702 includes a table class view index subunit, and is configured to perform the following processing:
judging the view type of the view as a table type view;
and determining the view index according to the block position of the view.
Optionally, the block position is identified by a section sequence number and a row sequence number.
Optionally, the conventional view at least includes any one of the following views: tab view, root view of view tree, button view.
Optionally, the global multiplexing view at least includes any one of the following views: navigation bar view, layout container view.
Optionally, the table class view at least includes any one of the following views: table view, collection view.
Optionally, the traversing from the root view to the target view of the view tree includes: traversal according to depth first or traversal according to breadth first.
Optionally, the view identifier generating unit 703 is specifically configured to perform the following processing: and generating the view identification of the target view according to the parent view identification of the target view, the view index of the target view and the view type information of the target view.
Corresponding to the embodiment of the positioning method for the interface view, the application also provides a positioning device for the interface view.
Referring to fig. 8, a schematic diagram of a positioning device for an interface view is shown according to the present application. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple, and the relevant portions only need to refer to the corresponding description of the method embodiment. The device embodiments described below are merely illustrative.
The present application provides a positioning device for an interface view, comprising:
a first view path generating unit 801, configured to tear down, according to a predetermined rule, a view index and a view type of a target view and a view index and a view type of each level of parent views of the target view from a given view identifier, and compose a first view path by using child nodes described by the view index and the view type according to a parent-child view hierarchical relationship;
a positioning unit 802, configured to traverse the second view tree from the root view, generate, according to the predetermined rule, a view index and a view type for the traversed current view, and position an information consistent child node in the first view path according to the view index and the view type.
A target view determining unit 803, configured to determine whether an information consistent child node is located, and whether the child node is the last node in the first view path; if yes, the current view is the positioned target view.
Optionally, the predetermined rule refers to a rule for constructing a view identifier, and the view identifier constructed by the rule at least includes the following components:
parent view identification, view index, view type information.
Optionally, the generating method of the view index includes: and generating a view index by adopting a corresponding index rule according to the view type.
Optionally, the positioning unit 802 includes a conventional view indexing subunit, and is configured to perform the following processing:
judging the view to be a conventional view;
the view index is maintained according to the order of addition of the views.
Optionally, the positioning unit 802 includes a global multiplexing view indexing subunit, and is configured to perform the following processing:
judging the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
Optionally, the positioning unit 802 includes a table class view indexing subunit, and is configured to perform the following processing:
judging the view as a table class view;
and determining the view index according to the block position of the view.
Optionally, the target view determining unit 803 includes a sub-view traversal sub-unit, configured to perform the following processing after determining whether an information consistent sub-node is located:
traversing breadth-first a sub-view of a current view of the second view tree under the current view.
Optionally, the target view determining unit 803 includes a fuzzy positioning subunit, configured to perform the following processing after determining whether the information consistent child node is located:
if the information consistency child node is not positioned, judging that the view types are inconsistent, and then carrying out fuzzy positioning.
Optionally, the fuzzy positioning subunit is specifically configured to perform the following processing: and judging all the sub-views in the current view as alternative views according with the view type information, and positioning the alternative views to the target view in the first view path according to the view indexes and the view types of the alternative views.
Optionally, traversing the second view tree from the root view includes: traversal is prioritized by breadth.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
1. Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
2. As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application, and those skilled in the art can make variations and modifications without departing from the spirit and scope of the present application, therefore, the scope of the present application should be determined by the claims that follow.

Claims (27)

1. An identification method for an interface view, comprising:
acquiring a view tree;
traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type;
and determining the view identification of the root view, and determining the view identification of each level of view on the view path from the direct sub-view of the root view step by step based on the view identification of the root view and the view indexes and view types of the views on each level of the view path.
2. The method according to claim 1, wherein the view type comprises any one of the following types:
regular view, global multiplex view, table class view.
3. The method according to claim 2, wherein the determining the view index of each view according to the view type by using the corresponding index rule comprises:
judging the view type of the view as a conventional view;
the view index is maintained according to the order of addition of the views.
4. The method according to claim 3, wherein said maintaining the view index according to the adding order of the view comprises the following processes:
monitoring addition, removal and view level change events of each view in the view tree;
when the view is added, setting the view index of the view according to the number of the child views in the parent view of the view.
5. The method according to claim 3, wherein said maintaining the view index according to the adding order of the view further comprises the following processes:
monitoring addition, removal and view level change events of each view in the view tree;
when it is monitored that the view is removed from its parent view, the view identification of the view and all its child views is reset.
6. The method according to claim 3, wherein said maintaining the view index according to the adding order of the view further comprises the following processes:
and when the view is added to the parent view, dynamically generating the view indexes according to the adding sequence.
7. The method according to claim 2, wherein the determining the view index of each view according to the view type by using the corresponding index rule comprises:
judging the view type of the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
8. The method of claim 7, wherein the predetermined sorting priority is sorted from high to low according to the following priorities: view Y axis location, view X axis location, whether the view is system private type, whether the view is hidden.
9. The method according to claim 2, wherein the determining the view index of each view according to the view type by using the corresponding index rule comprises:
judging the view type of the view as a table type view;
and determining the view index according to the block position of the view.
10. The method of claim 9, wherein the block location is identified by a section sequence number and a row sequence number.
11. The method according to claim 2, wherein the regular view comprises at least any one of the following views: tab view, root view of view tree, button view.
12. The method according to claim 2, wherein the globally multiplexed view comprises at least any one of: navigation bar view, layout container view.
13. The method of claim 2, wherein the table class view comprises at least one of the following views: table view, collection view.
14. The method of claim 2, wherein traversing from a root view to a target view of the view tree comprises: traversal according to depth first or traversal according to breadth first.
15. The method according to claim 1, wherein said determining the view identifier of each level of view on the view path stage by stage comprises: and generating the view identification of the target view according to the parent view identification of the target view, the view index of the target view and the view type information of the target view.
16. A positioning method for an interface view, comprising:
according to a preset rule, detaching a view index and a view type of a target view from a given view identifier and view indexes and view types of all levels of parent views of the target view, and forming a first view path by using child nodes described by the view indexes and the view types according to a parent-child view hierarchical relationship;
traversing a second view tree from the root view, generating a view index and a view type for the traversed current view according to the predetermined rule, and positioning an information consistent child node in the first view path according to the view index and the view type;
judging whether an information consistency child node is positioned or not and whether the child node is the last node in the first view path or not; if yes, the current view is the positioned target view.
17. The method according to claim 16, wherein the predetermined rule is a rule for constructing a view identifier, and the view identifier constructed by the rule at least comprises the following components:
parent view identification, view index, view type information.
18. The method according to claim 17, wherein the view index is generated by a method comprising: and generating a view index by adopting a corresponding index rule according to the view type.
19. The method of claim 18, wherein generating the view index according to the view type by using the corresponding index rule comprises:
judging the view to be a conventional view;
the view index is maintained according to the order of addition of the views.
20. The method of claim 18, wherein generating the view index according to the view type by using the corresponding index rule comprises:
judging the view as a global multiplexing view;
and according to the position sorting of the view on the interface, determining the view index according to the preset sorting priority.
21. The method of claim 18, wherein generating the view index according to the view type by using the corresponding index rule comprises:
judging the view as a table class view;
and determining the view index according to the block position of the view.
22. The method of claim 16, wherein said determining whether an information-consistent child node is located further comprises, after said determining, the steps of:
traversing breadth-first a sub-view of a current view of the second view tree under the current view.
23. The method of claim 16, wherein said determining whether an information-consistent child node is located further comprises, after said determining, the steps of:
if the information consistency child node is not positioned, judging that the view types are inconsistent, and then carrying out fuzzy positioning.
24. The method of claim 23, wherein the ambiguous location comprises: and judging all the sub-views in the current view as alternative views according with the view type information, and positioning the alternative views to the target view in the first view path according to the view indexes and the view types of the alternative views.
25. The method of claim 16, wherein traversing the second view tree from the root view comprises: traversal is prioritized by breadth.
26. An identification device for an interface view, comprising:
the view tree generating unit is used for acquiring a view tree;
the view index generating unit is used for traversing the root view of the view tree to a target view, acquiring a view path of the target view, determining the view type of each view on the view path, and determining the view index of each view by adopting a corresponding index rule according to the view type;
and the view identifier generating unit is used for determining the view identifier of the root view, and determining the view identifiers of the views at all levels on the view path step by step from the direct sub-view of the root view based on the view identifier of the root view and the view indexes and view types of the views at all levels on the view path.
27. A positioning device for an interface view, comprising:
a first view path generating unit, configured to tear down, according to a predetermined rule, a view index and a view type of a target view and a view index and a view type of each level of parent views of the target view from a given view identifier, and compose a first view path from child nodes described by the view index and the view type according to a hierarchical relationship between parent views and child views;
the positioning unit is used for traversing the second view tree from the root view, generating a view index and a view type for the traversed current view according to the preset rule, and positioning an information consistent child node in the first view path according to the view index and the view type;
the target view determining unit is used for judging whether an information consistency child node is positioned or not and whether the child node is the last node in the first view path or not; if yes, the current view is the positioned target view.
CN201810090424.XA 2018-01-30 2018-01-30 Identification method and device for interface view Active CN108345485B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810090424.XA CN108345485B (en) 2018-01-30 2018-01-30 Identification method and device for interface view

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810090424.XA CN108345485B (en) 2018-01-30 2018-01-30 Identification method and device for interface view

Publications (2)

Publication Number Publication Date
CN108345485A CN108345485A (en) 2018-07-31
CN108345485B true CN108345485B (en) 2021-05-07

Family

ID=62960745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810090424.XA Active CN108345485B (en) 2018-01-30 2018-01-30 Identification method and device for interface view

Country Status (1)

Country Link
CN (1) CN108345485B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359222B (en) * 2018-08-06 2021-07-06 杭州复杂美科技有限公司 Data storage method and system, equipment and storage medium
CN109144652B (en) * 2018-08-28 2021-11-09 武汉斗鱼网络科技有限公司 View display method and device, electronic equipment and storage medium
CN110875869B (en) * 2018-08-31 2022-05-31 Oppo广东移动通信有限公司 Red packet identification method, system and terminal equipment
CN110875876B (en) * 2018-09-04 2022-05-27 Oppo广东移动通信有限公司 Electronic red packet identification method, electronic red packet identification device and mobile terminal
CN111309583B (en) * 2018-12-11 2023-07-11 网易(杭州)网络有限公司 Interface overdrawing detection method, device, medium and computing equipment
CN110320846B (en) * 2019-07-29 2020-11-03 珠海格力电器股份有限公司 Configuration software variable binding method and device and storage medium
CN110838034A (en) * 2019-12-04 2020-02-25 珠海格力电器股份有限公司 Function segment type selection method, storage device and processor
CN111522548B (en) * 2020-03-24 2023-06-27 北京三快在线科技有限公司 Project function expansion method, apparatus, electronic device and computer readable medium
CN111666076B (en) * 2020-06-02 2023-09-26 广州酷狗计算机科技有限公司 Layer adding method, device, terminal and storage medium
CN111897465B (en) * 2020-08-07 2022-03-15 广州酷狗计算机科技有限公司 Popup display method, device, equipment and storage medium
CN112506766B (en) * 2020-12-02 2023-06-20 华南理工大学 Automatic generation method of interactive test case
CN112988304B (en) * 2021-03-25 2022-04-29 腾讯科技(深圳)有限公司 Recording method and device of operation mode, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309797A (en) * 2012-03-09 2013-09-18 阿里巴巴集团控股有限公司 Automatic testing method and device of user interface
JP2014142880A (en) * 2013-01-25 2014-08-07 Canon Inc Device and method capable of handling utterance, and program
CN104615538A (en) * 2015-02-05 2015-05-13 天津市康凯特软件科技有限公司 Mobile phone application testing method based on mobile phone interface control elements
CN105204992A (en) * 2015-08-28 2015-12-30 努比亚技术有限公司 Test script generating device and method
CN105630512A (en) * 2016-02-17 2016-06-01 北京高绎信息技术有限公司 Method and system for implementing mobile device data tracking through software development toolkit

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060047714A1 (en) * 2004-08-30 2006-03-02 Mendocino Software, Inc. Systems and methods for rapid presentation of historical views of stored data
US20160275000A1 (en) * 2015-03-17 2016-09-22 Wegilant Net Solutions Pvt. Ltd. System and method of automated application screen flow generation for detecting aberration in mobile application

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309797A (en) * 2012-03-09 2013-09-18 阿里巴巴集团控股有限公司 Automatic testing method and device of user interface
JP2014142880A (en) * 2013-01-25 2014-08-07 Canon Inc Device and method capable of handling utterance, and program
CN104615538A (en) * 2015-02-05 2015-05-13 天津市康凯特软件科技有限公司 Mobile phone application testing method based on mobile phone interface control elements
CN105204992A (en) * 2015-08-28 2015-12-30 努比亚技术有限公司 Test script generating device and method
CN105630512A (en) * 2016-02-17 2016-06-01 北京高绎信息技术有限公司 Method and system for implementing mobile device data tracking through software development toolkit

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
SPS: Distributed view indexing;K. Dhanasree ET AL;《2015 IEEE International Conference on Computational Intelligence and Computing Research (ICCIC)》;20160321;全文 *
跨平台嵌入式GUI开发模式的设计与应用;王宇航;《中国优秀硕士学位论文全文数据库 信息科技辑》;20140415;第2014年卷(第4期);全文 *

Also Published As

Publication number Publication date
CN108345485A (en) 2018-07-31

Similar Documents

Publication Publication Date Title
CN108345485B (en) Identification method and device for interface view
CN103309797B (en) User interface automated testing method and device
CN107040578B (en) Data synchronization method, device and system
CN111209344A (en) Data synchronization method and device
CN109936474B (en) Method and equipment for generating network topological graph
CN110968509B (en) Method and system for batch customizing of variables
CN103617209A (en) File management method and file management device for mobile terminal
CN109582305B (en) Encoding method and device for mobile application page elements and electronic equipment
CN107609179B (en) Data processing method and equipment
CN106919390A (en) A kind of method and apparatus of page generation
CN110442583B (en) Data processing method and device, electronic equipment and storage medium
CN106354587A (en) Mirror image server and method for exporting mirror image files of virtual machine
CN103902543A (en) Database inquiry method and device and database system
CN111414168B (en) Web application development method and device based on mind map and electronic equipment
CN113485909A (en) Test method, test device, computing device, and medium
CN110659393B (en) Method and system for generating xml code
CN107590044B (en) Testing method, device and equipment for distributed storage cluster
CN115412452A (en) Configuration navigation method, device and medium based on physical layer Fabric scene
CN110209453A (en) It is multipair as refreshing automatically and display methods and Related product based on driver
CN112765041B (en) Game automation testing method and device and electronic equipment
CN111563123B (en) Real-time synchronization method for hive warehouse metadata
CN111352824B (en) Test method and device and computer equipment
CN113253708A (en) Method and device for automatically generating simulation tool configuration file for signal system test
CN113760907A (en) Data uniqueness identification method in database
CN109067572A (en) Method, device and equipment based on order edlin SNMP configuration file

Legal Events

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