Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __view_beside(self, onsideof, **kwargs):
bounds = self.info["bounds"]
min_dist, found = -1, None
for ui in UiObject(self.session, Selector(**kwargs)):
dist = onsideof(bounds, ui.info["bounds"])
if dist >= 0 and (min_dist < 0 or dist < min_dist):
min_dist, found = dist, ui
return found
def __call__(self, **kwargs):
return UiObject(self, Selector(**kwargs))
def child_by_description(self, txt, **kwargs):
# need test
if "allow_scroll_search" in kwargs:
allow_scroll_search = kwargs.pop("allow_scroll_search")
name = self.jsonrpc.childByDescription(self.selector,
Selector(**kwargs), txt,
allow_scroll_search)
else:
name = self.jsonrpc.childByDescription(self.selector,
Selector(**kwargs), txt)
return UiObject(self.session, name)
def child_by_text(self, txt, **kwargs):
if "allow_scroll_search" in kwargs:
allow_scroll_search = kwargs.pop("allow_scroll_search")
name = self.jsonrpc.childByText(self.selector, Selector(**kwargs),
txt, allow_scroll_search)
else:
name = self.jsonrpc.childByText(self.selector, Selector(**kwargs),
txt)
return UiObject(self.session, name)
def __getitem__(self, index):
"""
Raises:
IndexError
"""
if isinstance(self.selector, six.string_types):
raise IndexError(
"Index is not supported when UiObject returned by child_by_xxx"
)
selector = self.selector.clone()
selector.update_instance(index)
return UiObject(self.session, selector)
def child(self, **kwargs):
return UiObject(self.session, self.selector.clone().child(**kwargs))