How to use sendTouchDown method in fMBT

Best Python code snippet using fMBT_python

ui_keywords.py

Source:ui_keywords.py Github

copy

Full Screen

...459#-----------------------------------------------------------------------------# 460class TapDownCoordinate(TapCoordinate):461 462 def doTap(self,x,y):463 return self._target.getMonkeyDriver().sendTouchDown(x,y) 464 465#-----------------------------------------------------------------------------# 466class TapUpCoordinate(TapCoordinate):467 468 def doTap(self,x,y):469 return self._target.getMonkeyDriver().sendTouchUp(x,y) 470#-----------------------------------------------------------------------------# 471class LongTapCoordinate(TapCoordinate):472 473 def doTap(self,x,y):474 475 if self._target.getMonkeyDriver().sendTouchDown(x,y):476 time.sleep(self.__hold_time)477 return self._target.getMonkeyDriver().sendTouchUp(x,y)478 return False479 480 def execute(self):481 482 matcher = self.attributePattern.match(self.attributes)483 self.__hold_time = 2484 485 if matcher.group("times"):486 self.__hold_time = int(matcher.group("times"))487 if not self.doTap(matcher.group(1),matcher.group(2)):488 return False489 490 return True491#-----------------------------------------------------------------------------#492class MoveToCoordinate(TapCoordinate):493 494 def doTap(self,x,y):495 return self._target.getMonkeyDriver().sendTouchMove(x,y) 496 497#-----------------------------------------------------------------------------# 498class TapObject(ObjectKeyword):499 500 """501 Taps the given component.502 503 Usage:504 kw_TapObject componentReferece505 """506 507 def __init__(self):508 super(TapObject,self).__init__()509 pattern = re.compile("((?P<times>\d+)\s*,\s*)?(?P<component>" + self.componentPattern + ")")510 self.attributePattern = pattern 511 512 def doTapAction(self,x,y):513 return self._target.getMonkeyDriver().sendTap(x,y) 514 515 def doTap(self,reference, times = 1): 516 517 item = self.findComponentReference(reference)518 519 if not item:520 return False 521 522 try:523 524 x,y = self._target.getGUIReader().getViewCoordinates(item)525 except guireader.GuiReaderError,e:526 print e527 return False528 529 for i in range(0,times):530 if not self.doTapAction(x,y):531 return False532 if times > 1:533 time.sleep(TAP_INTERVAL)534 return True535 536 def execute(self):537 matcher = self.attributePattern.match(self.attributes)538 539 times = 1540 if matcher.group("times"):541 times = int(matcher.group("times"))542 543 return self.doTap(matcher.group("component"),times) 544 545 546#-----------------------------------------------------------------------------# 547class TapDownObject(TapObject):548 549 def doTapAction(self,x,y):550 return self._target.getMonkeyDriver().sendTouchDown(x,y) 551 552#-----------------------------------------------------------------------------# 553class TapUpObject(TapObject):554 555 def doTapAction(self,x,y):556 return self._target.getMonkeyDriver().sendTouchUp(x,y) 557#-----------------------------------------------------------------------------# 558class LongTapObject(TapObject):559 560 def doTapAction(self,x,y):561 562 if self._target.getMonkeyDriver().sendTouchDown(x,y):563 time.sleep(self.__hold_time)564 return self._target.getMonkeyDriver().sendTouchUp(x,y)565 return False566 567 568 def execute(self):569 matcher = self.attributePattern.match(self.attributes)570 571 times = 1572 self.__hold_time = 2573 if matcher.group("times"):574 self.__hold_time = int(matcher.group("times"))575 576 return self.doTap(matcher.group("component"),times) 577 578#-----------------------------------------------------------------------------# 579class MoveToObject(TapObject):580 581 def doTapAction(self,x,y):582 return self._target.getMonkeyDriver().sendTouchMove(x,y) 583#-----------------------------------------------------------------------------# 584class Drag(ObjectKeyword):585 586 def __init__(self):587 super(Drag,self).__init__()588 pattern = re.compile("((?P<coord1>(?P<x1>\d+)\s*,\s*(?P<y1>\d+))|(?P<component1>.+))\s*-->\s*((?P<coord2>(?P<x2>\d+)\s*,\s*(?P<y2>\d+))|(?P<component2>.*))") 589 self.attributePattern = pattern 590 self._holdtime = 2591 self._dragtime = 0.001592 self._movepoints = 20593 594 595 def execute(self):596 597 matcher = self.attributePattern.match(self.attributes)598 599 if matcher.group("coord1"):600 x1 = int(matcher.group("x1"))601 y1 = int(matcher.group("y1"))602 else:603 604 item = self.findComponentReference(matcher.group("component1").strip())605 if not item:606 return False607 608 try: 609 x1,y1 = self._target.getGUIReader().getViewCoordinates(item)610 except guireader.GuiReaderError,e:611 612 print e613 return False614 615 #Tap down the first coordinate616 if not self._target.getMonkeyDriver().sendTouchDown(x1,y1):617 return False618 619 620 if matcher.group("coord2"):621 x2 = int(matcher.group("x2"))622 y2 = int(matcher.group("y2"))623 time.sleep(self._holdtime)624 else:625 626 item = self.findComponentReference(matcher.group("component2").strip())627 if not item:628 return False629 try:630 ...

Full Screen

Full Screen

fmbtchromiumos.py

Source:fmbtchromiumos.py Github

copy

Full Screen

...194 command = "x.sendTap(%s, %s)" % (x, y)195 else:196 command = "x.sendTap(%s, %s, %s)" % (x, y, button)197 return self.agentEval(command)198 def sendTouchDown(self, x, y, button=None):199 if button == None:200 # TODO: synthesize touch display event, if available201 command = "x.sendTouchDown(%s, %s)" % (x, y)202 else:203 command = "x.sendTouchDown(%s, %s, %s)" % (x, y, button)204 return self.agentEval(command)205 def sendTouchMove(self, x, y, button=None):206 if button == None:207 # TODO: synthesize touch display event, if available208 command = "x.sendTouchMove(%s, %s)" % (x, y)209 else:210 command = "x.sendTouchMove(%s, %s)" % (x, y)211 return self.agentEval(command)212 def sendTouchUp(self, x, y, button=None):213 if button == None:214 # TODO: synthesize touch display event, if available215 command = "x.sendTouchUp(%s, %s)" % (x, y)216 else:217 command = "x.sendMouseUp(%s, %s, %s)" % (x, y, button)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful