How to use _archiveScreenshots method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...1172 else:1173 widthHeight = self._screenshotArchiveMethod.split()[1]1174 convertArgs = ["-resize", widthHeight]1175 subprocess.call(["convert", filepath] + convertArgs + [filepath])1176 def _archiveScreenshots(self):1177 """1178 Archive screenshot files if screenshotLimit has been exceeded.1179 """1180 freeScreenshots = [filename1181 for (filename, refCount) in self._screenshotRefCount.iteritems()1182 if refCount == 0]1183 archiveCount = len(freeScreenshots) - self._screenshotLimit1184 if archiveCount > 0:1185 freeScreenshots.sort(reverse=True) # archive oldest1186 while archiveCount > 0:1187 toBeArchived = freeScreenshots.pop()1188 try:1189 self._archiveScreenshot(toBeArchived)1190 except IOError:1191 pass1192 del self._screenshotRefCount[toBeArchived]1193 archiveCount -= 11194 def refreshScreenshot(self, forcedScreenshot=None, rotate=None):1195 """1196 Takes new screenshot and updates the latest screenshot object.1197 Parameters:1198 forcedScreenshot (Screenshot or string, optional):1199 use given screenshot object or image file, do not1200 take new screenshot.1201 rotate (integer, optional):1202 rotate screenshot by given number of degrees. This1203 overrides constructor rotateScreenshot parameter1204 value. The default is None (no override).1205 Returns Screenshot object, and makes the same object "the1206 latest screenshot" that is used by all *Bitmap and *OcrText1207 methods.1208 """1209 if forcedScreenshot != None:1210 if type(forcedScreenshot) == str:1211 self._lastScreenshot = Screenshot(1212 screenshotFile=forcedScreenshot,1213 paths = self._paths,1214 ocrEngine=self._ocrEngine,1215 oirEngine=self._oirEngine,1216 screenshotRefCount=self._screenshotRefCount)1217 else:1218 self._lastScreenshot = forcedScreenshot1219 else:1220 if self.screenshotDir() == None:1221 self.setScreenshotDir(self._screenshotDirDefault)1222 if self.screenshotSubdir() == None:1223 self.setScreenshotSubdir(self._screenshotSubdirDefault)1224 screenshotFile = self._newScreenshotFilepath()1225 if self._conn.recvScreenshot(screenshotFile):1226 # New screenshot successfully received from device1227 if rotate == None:1228 rotate = self._rotateScreenshot1229 if rotate != None and rotate != 0:1230 subprocess.call(["convert", screenshotFile, "-rotate", str(rotate), screenshotFile])1231 self._lastScreenshot = Screenshot(1232 screenshotFile=screenshotFile,1233 paths = self._paths,1234 ocrEngine=self._ocrEngine,1235 oirEngine=self._oirEngine,1236 screenshotRefCount=self._screenshotRefCount)1237 else:1238 self._lastScreenshot = None1239 # Make sure unreachable Screenshot instances are released from1240 # memory.1241 gc.collect()1242 for obj in gc.garbage:1243 if isinstance(obj, Screenshot):1244 if hasattr(obj, "_logCallReturnValue"):1245 # Some methods have been wrapped by visual1246 # log. Break reference cycles to let gc collect1247 # them.1248 del obj.findItemsByBitmap1249 del obj.findItemsByOcr1250 del gc.garbage[:]1251 gc.collect()1252 # If screenshotLimit has been set, archive old screenshot1253 # stored on the disk.1254 if self._screenshotLimit != None and self._screenshotLimit >= 0:1255 self._archiveScreenshots()1256 return self._lastScreenshot1257 def screenshot(self):1258 """1259 Returns the latest Screenshot object.1260 Use refreshScreenshot() to get a new screenshot.1261 """1262 return self._lastScreenshot1263 def screenshotArchiveMethod(self):1264 """1265 Returns how screenshots exceeding screenshotLimit are archived.1266 """1267 return self._screenshotArchiveMethod1268 def screenshotDir(self):1269 """...

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