How to use setScreenshotSubdir method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...1219 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 """1270 Returns the directory under which new screenshots are saved.1271 """1272 return self._screenshotDir1273 def screenshotLimit(self):1274 """1275 Returns the limit after which unused screenshots are archived.1276 """1277 return self._screenshotLimit1278 def screenshotSubdir(self):1279 """1280 Returns the subdirectory in screenshotDir under which new1281 screenshots are stored.1282 """1283 return self._screenshotSubdir1284 def screenSize(self):1285 """1286 Returns screen size in pixels in tuple (width, height).1287 """1288 if self._screenSize == None:1289 if self._lastScreenshot == None:1290 self.refreshScreenshot()1291 self._screenSize = self._lastScreenshot.size()1292 self._lastScreenshot = None1293 else:1294 self._screenSize = self._lastScreenshot.size()1295 return self._screenSize1296 def setBitmapPath(self, bitmapPath, rootForRelativePaths=None):1297 """1298 Set new path for finding bitmaps.1299 Parameters:1300 bitmapPath (string)1301 colon-separated list of directories from which1302 bitmap methods look for bitmap files.1303 rootForRelativePaths (string, optional)1304 path that will prefix all relative paths in1305 bitmapPath.1306 Example:1307 gui.setBitmapPath("bitmaps:icons:/tmp", "/home/X")1308 gui.tapBitmap("start.png")1309 will look for /home/X/bitmaps/start.png,1310 /home/X/icons/start.png and /tmp/start.png, in this order.1311 """1312 self._paths.bitmapPath = bitmapPath1313 if rootForRelativePaths != None:1314 self._paths.relativeRoot = rootForRelativePaths1315 def setConnection(self, conn):1316 """1317 Set the connection object that performs actions on real target.1318 Parameters:1319 conn (GUITestConnection instance):1320 The connection to be used.1321 """1322 self._conn = conn1323 def setOcrEngine(self, ocrEngine):1324 """1325 Set OCR (optical character recognition) engine that will be1326 used by default in new screenshots.1327 Returns previous default.1328 """1329 prevDefault = self._ocrEngine1330 self._ocrEngine = ocrEngine1331 return prevDefault1332 def setOirEngine(self, oirEngine):1333 """1334 Set OIR (optical image recognition) engine that will be used1335 by default in new screenshots.1336 Returns previous default.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 be1402 stored to different subdirectories.1403 By default, all screenshots are stored directly to screenshotDir().1404 """1405 self._screenshotSubdir = screenshotSubdir1406 def swipe(self, (x, y), direction, distance=1.0, **dragArgs):1407 """1408 swipe starting from coordinates (x, y) to given direction.1409 Parameters:1410 coordinates (floats in range [0.0, 1.0] or integers):1411 floating point coordinates in range [0.0, 1.0] are1412 scaled to full screen width and height, others are...

Full Screen

Full Screen

fmbtx11.py

Source:fmbtx11.py Github

copy

Full Screen

...265 foundItems = self.existingConnection().recvAtspiViewData(window)266 if self.screenshotDir() == None:267 self.setScreenshotDir(self._screenshotDirDefault)268 if self.screenshotSubdir() == None:269 self.setScreenshotSubdir(self._screenshotSubdirDefault)270 viewFilename = self._newScreenshotFilepath()[:-3] + "view"271 file(viewFilename, "w").write(repr(foundItems))272 self._lastView = View(273 viewFilename, foundItems,274 itemOnScreen=lambda i: self.itemOnScreen(i))275 else:276 raise ValueError('viewSource "%s" not supported' % (viewSource,))277 return self._lastView278 def refreshViewDefaults(self):279 return self._refreshViewDefaults280 def setRefreshViewDefaults(self, **kwargs):281 """Set default arguments for refreshView() calls282 Parameters:283 **kwargs (keyword arguments)...

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