MCPcopy Index your code
hub / github.com/AirtestProject/Poco / __iter__

Method __iter__

poco/proxy.py:274–308  ·  view source on GitHub ↗

Similar method to :py:meth:`.__getitem__() ` with the difference that this method iterates over all UI elements. The order rules of UI elements is same as for :py:meth:`.__getitem__() `. See ``Iterat

(self)

Source from the content-addressed store, hash-verified

272 return len(nodes) if nodes else 0
273
274 def __iter__(self):
275 """
276 Similar method to :py:meth:`.__getitem__() <poco.proxy.UIObjectProxy.__getitem__>` with the difference that this
277 method iterates over all UI elements. The order rules of UI elements is same as for :py:meth:`.__getitem__()
278 <poco.proxy.UIObjectProxy.__getitem__>`. See ``IterationOverUI`` for more details.
279
280 Yields:
281 :py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: a generator yielding new UI proxy represents the
282 specific UI element iterated over
283
284 Raises:
285 PocoTargetRemovedException: when hierarchy structure has changed and it is attempted to access to the
286 nonexistent UI element over the iteration
287 """
288
289 # 节点数量太多时,就不按照控件顺序排序了
290 if not self._query_multiple:
291 nodes = self._do_query(multiple=True, refresh=True)
292 else:
293 nodes = self._nodes
294 length = len(nodes)
295 sorted_nodes = []
296 for i in range(length):
297 uiobj = UIObjectProxy(self.poco)
298 uiobj.query = ('index', (self.query, i))
299 uiobj._evaluated = True
300 uiobj._query_multiple = True
301 uiobj._nodes = nodes[i]
302 uiobj._nodes_proxy_is_list = False
303 pos = uiobj.get_position()
304 sorted_nodes.append((uiobj, pos))
305 sorted_nodes.sort(key=lambda v: (v[1][1], v[1][0]))
306
307 for obj, _ in sorted_nodes:
308 yield obj
309
310 @wait
311 def click(self, focus=None, sleep_interval=None):

Callers

nothing calls this directly

Calls 3

_do_queryMethod · 0.95
get_positionMethod · 0.95
UIObjectProxyClass · 0.85

Tested by

no test coverage detected