Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def drag_to(self, *args, **kwargs):
duration = kwargs.pop('duration', 0.5)
timeout = kwargs.pop('timeout', None)
self.must_wait(timeout=timeout)
steps = int(duration * 200)
if len(args) >= 2 or "x" in kwargs or "y" in kwargs:
def drag2xy(x, y):
x, y = self.session.pos_rel2abs(x,
y) # convert percent position
return self.jsonrpc.dragTo(self.selector, x, y, steps)
return drag2xy(*args, **kwargs)
return self.jsonrpc.dragTo(self.selector, Selector(**kwargs), steps)
def child(self, **kwargs):
self[self.__childOrSibling].append("child")
self[self.__childOrSiblingSelector].append(Selector(**kwargs))
return self
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_instance(self, inst, **kwargs):
# need test
return UiObject(
self.session,
self.jsonrpc.childByInstance(self.selector, Selector(**kwargs),
inst))
def __call__(self, steps=20, max_swipes=500, **kwargs):
if self.action in ["forward", "backward"]:
method = jsonrpc.scrollForward if self.action == "forward" else jsonrpc.scrollBackward
return method(selector, self.vertical, steps)
elif self.action == "toBeginning":
return jsonrpc.scrollToBeginning(selector, self.vertical,
max_swipes, steps)
elif self.action == "toEnd":
return jsonrpc.scrollToEnd(selector, self.vertical,
max_swipes, steps)
elif self.action == "to":
return jsonrpc.scrollTo(selector, Selector(**kwargs),
self.vertical)