Select the specific UI element by index. If this UI proxy represents a set of UI elements, then use this method to access the specific UI element. The new UI element will be wrapped by UIObjectProxy instance and therefore the returned value is also the UI proxy object.
(self, item)
| 209 | return obj |
| 210 | |
| 211 | def __getitem__(self, item): |
| 212 | """ |
| 213 | Select the specific UI element by index. If this UI proxy represents a set of UI elements, then use this method |
| 214 | to access the specific UI element. The new UI element will be wrapped by UIObjectProxy instance and therefore |
| 215 | the returned value is also the UI proxy object. |
| 216 | |
| 217 | The order of UI elements are determined by their position on the screen and not by the selection sequence. This |
| 218 | rule is called "L2R U2D" (one by one from left to right, line by line from up to down), i.e. the most top left |
| 219 | UI element is always the first one. See ``IterationOverUI`` for more details. |
| 220 | |
| 221 | Warnings: |
| 222 | This method may cause some performance issues depending on implementation of PocoAgent. |
| 223 | |
| 224 | Args: |
| 225 | item (:obj:`int`): the index. |
| 226 | |
| 227 | Returns: |
| 228 | :py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: a new UI proxy object representing the n-th of the |
| 229 | current UI elements. |
| 230 | """ |
| 231 | |
| 232 | if not self._query_multiple: |
| 233 | nodes = self._do_query(multiple=True, refresh=True) |
| 234 | else: |
| 235 | nodes = self._nodes |
| 236 | length = len(nodes) |
| 237 | if not self._sorted_children: |
| 238 | self._sorted_children = [] |
| 239 | for i in range(length): |
| 240 | uiobj = UIObjectProxy(self.poco) |
| 241 | uiobj.query = ('index', (self.query, i)) |
| 242 | uiobj._evaluated = True |
| 243 | uiobj._query_multiple = True |
| 244 | uiobj._nodes = nodes[i] |
| 245 | uiobj._nodes_proxy_is_list = False |
| 246 | pos = uiobj.get_position() |
| 247 | self._sorted_children.append((uiobj, pos)) |
| 248 | |
| 249 | self._sorted_children.sort(key=lambda v: (v[1][1], v[1][0])) |
| 250 | return self._sorted_children[item][0] |
| 251 | |
| 252 | def __len__(self): |
| 253 | """ |
nothing calls this directly
no test coverage detected