How to use iActiveWindow method in fMBT

Best Python code snippet using fMBT_python

eyenfinger.py

Source:eyenfinger.py Github

copy

Full Screen

...1257def iUseWindow(windowIdOrName = None):1258 global _g_lastWindow1259 if windowIdOrName == None:1260 if _g_lastWindow == None:1261 _g_lastWindow = iActiveWindow()1262 elif windowIdOrName.startswith("0x"):1263 _g_lastWindow = windowIdOrName1264 else:1265 _g_lastWindow = _runcmd("xwininfo -name '%s' | awk '/Window id: 0x/{print $4}'" %1266 (windowIdOrName,))[1].strip()1267 if not _g_lastWindow.startswith("0x"):1268 raise BadWindowName('Cannot find window id for "%s" (got: "%s")' %1269 (windowIdOrName, _g_lastWindow))1270 _, output = _runcmd("xwininfo -id %s | awk '/Width:/{w=$NF}/Height:/{h=$NF}/Absolute upper-left X/{x=$NF}/Absolute upper-left Y/{y=$NF}END{print x\" \"y\" \"w\" \"h}'" %1271 (_g_lastWindow,))1272 offset_x, offset_y, width, height = output.split(" ")1273 _g_windowOffsets[_g_lastWindow] = (int(offset_x), int(offset_y))1274 _g_windowSizes[_g_lastWindow] = (int(width), int(height))1275 _getScreenSize()1276 return _g_lastWindow1277def iUseImageAsWindow(imageFilename):1278 global _g_lastWindow1279 global _g_screenSize1280 if not eye4graphics:1281 _log('ERROR: iUseImageAsWindow("%s") called, but eye4graphics not loaded.' % (imageFilename,))1282 raise EyenfingerError("eye4graphics not available")1283 if not os.access(imageFilename, os.R_OK):1284 raise BadSourceImage("The input file could not be read or not present.")1285 _g_lastWindow = imageFilename1286 imageWidth, imageHeight = imageSize(imageFilename)1287 if imageWidth == None:1288 _log('iUseImageAsWindow: Failed reading dimensions of image "%s".' % (imageFilename,))1289 raise BadSourceImage('Failed to read dimensions of "%s".' % (imageFilename,))1290 _g_windowOffsets[_g_lastWindow] = (0, 0)1291 _g_windowSizes[_g_lastWindow] = (imageWidth, imageHeight)1292 _g_screenSize = _g_windowSizes[_g_lastWindow]1293 return _g_lastWindow1294def iActiveWindow(windowId = None):1295 """ return id of active window, in '0x1d0f14' format """1296 if windowId == None:1297 _, output = _runcmd("xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}'")1298 windowId = output.strip()1299 return windowId1300def drawBboxes(inputfilename, outputfilename, bboxes):1301 """1302 Draw bounding boxes1303 """1304 if inputfilename == None:1305 return1306 draw_commands = []1307 for bbox in bboxes:1308 left, top, right, bottom = bbox...

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