How to use findItemsByOcrLogger method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...2112 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2113 retval._logCallReturnValue = logCallReturnValue2114 loggerSelf.logReturn(retval, img=retval, tip=origMethod.func_name)2115 retval.findItemsByBitmap = loggerSelf.findItemsByBitmapLogger(retval.findItemsByBitmap, retval)2116 retval.findItemsByOcr = loggerSelf.findItemsByOcrLogger(retval.findItemsByOcr, retval)2117 return retval2118 return refreshScreenshotWRAP2119 def tapLogger(loggerSelf, origMethod):2120 def tapWRAP(*args, **kwargs):2121 loggerSelf.logCall()2122 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2123 try:2124 screenshotFilename = loggerSelf._device.screenshot().filename()2125 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2126 eyenfinger.drawClickedPoint(screenshotFilename, highlightFilename, loggerSelf._device.intCoords(args[0]))2127 loggerSelf.logReturn(retval, img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=loggerSelf._device.screenshot()._logCallReturnValue)2128 except:2129 loggerSelf.logReturn(str(retval) + " (no screenshot available)", tip=origMethod.func_name)2130 return retval2131 return tapWRAP2132 def findItemsByBitmapLogger(loggerSelf, origMethod, screenshotObj):2133 def findItemsByBitmapWRAP(*args, **kwargs):2134 bitmap = args[0]2135 absPathBitmap = screenshotObj._paths.abspath(bitmap)2136 if loggerSelf._copyBitmapsToScreenshotDir:2137 screenshotDirBitmap = os.path.join(2138 os.path.dirname(screenshotObj.filename()),2139 "bitmaps",2140 bitmap.lstrip(os.sep))2141 if not os.access(screenshotDirBitmap, os.R_OK):2142 # bitmap is not yet copied under screenshotDir2143 destDir = os.path.dirname(screenshotDirBitmap)2144 if not os.access(destDir, os.W_OK):2145 try:2146 os.makedirs(destDir)2147 except IOError:2148 pass # cannot make dir / dir not writable2149 try:2150 shutil.copy(absPathBitmap, destDir)2151 absPathBitmap = screenshotDirBitmap2152 except IOError:2153 pass # cannot copy bitmap2154 else:2155 absPathBitmap = screenshotDirBitmap2156 loggerSelf.logCall(img=absPathBitmap)2157 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2158 if len(retval) == 0:2159 loggerSelf.logReturn("not found in", img=screenshotObj, tip=origMethod.func_name)2160 else:2161 foundItems = retval2162 screenshotFilename = screenshotObj.filename()2163 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2164 eyenfinger.drawIcon(screenshotFilename, highlightFilename, bitmap, [i.bbox() for i in foundItems])2165 loggerSelf.logReturn([str(quiItem) for quiItem in retval], img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=screenshotObj._logCallReturnValue)2166 return retval2167 return findItemsByBitmapWRAP2168 def findItemsByOcrLogger(loggerSelf, origMethod, screenshotObj):2169 def findItemsByOcrWRAP(*args, **kwargs):2170 loggerSelf.logCall()2171 retval = loggerSelf.doCallLogException(origMethod, args, kwargs)2172 if len(retval) == 0:2173 loggerSelf.logReturn("not found in words " + str(screenshotObj.dumpOcrWords()),2174 img=screenshotObj, tip=origMethod.func_name)2175 else:2176 foundItem = retval[0]2177 screenshotFilename = screenshotObj.filename()2178 highlightFilename = loggerSelf.highlightFilename(screenshotFilename)2179 eyenfinger.drawIcon(screenshotFilename, highlightFilename, args[0], foundItem.bbox())2180 for appearance, foundItem in enumerate(retval[1:42]):2181 eyenfinger.drawIcon(highlightFilename, highlightFilename, str(appearance+1) + ": " + args[0], foundItem.bbox())2182 loggerSelf.logReturn([str(retval[0])], img=highlightFilename, width=loggerSelf._screenshotWidth, tip=origMethod.func_name, imgTip=screenshotObj._logCallReturnValue)...

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