poco.sdk.Selector module¶
-
class
ISelector
[源代码]¶ 基类:
object
This interface defines the standard selector behavior. Selector is used for selecting the specific UI element(s) by given query expression (formal definitions are in specific implementation classes).
-
select
(cond, multiple=False)[源代码]¶ 参数: - cond (
tuple
) – query expressiom - multiple (
bool
) – whether or not to select the multiple elements. If set to True, the method terminates immediately once the node is found, otherwise it traverses through all nodes and then exists
返回: list <inherited from
AbstractNode
>返回类型: list
- cond (
-
-
class
Selector
(dumper, matcher=None)[源代码]¶ 基类:
poco.sdk.Selector.ISelector
This class implements the standard Selector interface that uses DFS algorithm to travers through tree-like hierarchy structure. It supports flexible query expressions such as parental relationship, attribute predicate, etc. Any combinations of expressions mentioned above are also allowed as the query conditions.
The query expression can be defined as follows:
expr := (op0, (expr0, expr1)) expr := ('index', (expr, :obj:`int`)) expr := <other query condition> See implementation of Matcher.
op0
can be one of the following (‘>’, ‘/’, ‘-‘), each operator stands for as follows:'>': offsprings, select all offsprings matched expr1 from all roots matched expr0. '/': children, select all children matched expr1 from all roots matched expr0. '-': siblings, select all siblings matched expr1 from all roots matched expr0. '^': parent, select the parent of 1st UI element matched expr0. expr1 is always None.
'index'
: select specific n-th UI element from the previous resultsothers
: passes the expression to matcher
参数: - dumper (any implementation of
IDumper
) – dumper for the selector - matcher (any implementation of
IMatcher
) –DefaultMatcher
instance by default.
-
selectImpl
(cond, multiple, root, maxDepth, onlyVisibleNode, includeRoot)[源代码]¶ Selector internal implementation. TODO: add later.
注解
This doc shows only the outline of the algorithm. Do not call this method in your code as this is an internal method.
参数: - cond (
tuple
) – query expression - multiple (
bool
) – whether or not to select multiple nodes. If true, all nodes that matches the given condition will return, otherwise, only the first node matches will. - root (inherited from
AbstractNode
) – start traversing from the given root node - maxDepth (
bool
) – max traversing depth - onlyVisibleNode (
bool
) – If True, skip those node which visibility (the value of visible attribute) is False. - includeRoot (
bool
) – whether not not to include the root node if its child(ren) match(es) the node
返回: - The same as
返回类型: list
<inherited fromAbstractNode
>- cond (