Best Python code snippet using fMBT_python
fmbtgti.py
Source:fmbtgti.py  
...1337        """1338        prevDefault = self._oirEngine1339        self._oirEngine = oirEngine1340        return prevDefault1341    def setScreenshotArchiveMethod(self, screenshotArchiveMethod):1342        """1343        Set method for archiving screenshots when screenshotLimit is exceeded.1344        Parameters:1345          screenshotArchiveMethod (string)1346                  Supported methods are "resize [WxH]" and "remove"1347                  where W and H are integers that define maximum width and1348                  height for an archived screenshot.1349                  The default method is "resize".1350        """1351        if screenshotArchiveMethod == "remove":1352            pass1353        elif screenshotArchiveMethod == "resize":1354            pass1355        elif screenshotArchiveMethod.startswith("resize"):1356            try:1357                w, h = screenshotArchiveMethod.split(" ")[1].split("x")1358            except:1359                raise ValueError("Invalid resize syntax")1360            try:1361                w, h = int(w), int(h)1362            except:1363                raise ValueError(1364                    "Invalid resize width or height, integer expected")1365        else:1366            raise ValueError('Unknown archive method "%s"' %1367                             (screenshotArchiveMethod,))1368        self._screenshotArchiveMethod = screenshotArchiveMethod1369    def setScreenshotDir(self, screenshotDir):1370        self._screenshotDir = screenshotDir1371        if not os.path.isdir(self.screenshotDir()):1372            try:1373                os.makedirs(self.screenshotDir())1374            except Exception, e:1375                _fmbtLog('creating directory "%s" for screenshots failed: %s' % (self.screenshotDir(), e))1376                raise1377    def setScreenshotLimit(self, screenshotLimit):1378        """1379        Set maximum number for unarchived screenshots.1380        Parameters:1381          screenshotLimit (integer)1382                  Maximum number of unarchived screenshots that are1383                  free for archiving (that is, not referenced by test code).1384                  The default is None, that is, there is no limit and1385                  screenshots are never archived.1386        See also:1387          setScreenshotArchiveMethod()1388        """1389        self._screenshotLimit = screenshotLimit1390    def setScreenshotSubdir(self, screenshotSubdir):1391        """1392        Define a subdirectory under screenshotDir() for screenshot files.1393        Parameters:1394          screenshotSubdir (string)1395                  Name of a subdirectory. The name should contain1396                  conversion specifiers supported by strftime.1397        Example:1398          sut.setScreenshotSubdir("%m-%d-%H")1399                  A screenshot taken on June 20th at 4.30pm will1400                  be stored to screenshotDir/01-20-16. That is,1401                  screenshots taken on different hours will be...testservice.py
Source:testservice.py  
...32      self.d = fmbtandroid.Device()33      self.d.refreshScreenshot().save(SCREENSHOT)34      self.screensize = self.__getimgsize(SCREENSHOT)35      self.d.setScreenshotLimit(10)36      self.d.setScreenshotArchiveMethod("remove")37    except:38      self.useFMBTDevice = False39    # When asking server to match the template being selected set to true40    self.livematching = False41    self.templates = ['template 1', 'template 2', 'template 3', 'template 4']42    self.id  = 043    self.img = self.__loadimage("./screenshot1.png", True)44    self.img2 = self.__loadimage("./screenshot2.png", True)45    self.resultimg = self.__loadimage("./machinevision-result.png", True)46    self.position   = RobotCoord(x=152,y=385,z=0.9,alfa=0)47  def __getimgsize(self, filename):48    pil = pilimage.open(filename)49    if self.useFMBTDevice and self.d._screenSize == None:50      self.d._screenSize = pil.size...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
