How to use __ocrArgs method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...291 """292 Returns what is recognized in the screenshot. For debugging293 purposes.294 """295 ocrArgs = self.__ocrArgs(screenshot, **kwargs)296 return self._dumpOcr(screenshot, **ocrArgs)297 def _dumpOcr(self, screenshot, **kwargs):298 return None299 def addScreenshot(self, screenshot, **findTextDefaults):300 """301 Prepare for finding text from the screenshot.302 Parameters:303 screenshot (fmbtgti.Screenshot)304 screenshot object to be searched from.305 other parameters (optional)306 findText defaults for this screenshot.307 Notice that there may be many screenshots simultaneously.308 Do not keep reference to the screenshot object.309 """310 self.setScreenshotFindTextDefaults(screenshot, **findTextDefaults)311 return self._addScreenshot(screenshot, **findTextDefaults)312 def _addScreenshot(self, screenshot, **findTextDefaults):313 pass314 def removeScreenshot(self, screenshot):315 """316 OCR queries on the screenshot will not be made anymore.317 """318 self._removeScreenshot(screenshot)319 try:320 del self._ssFindTextDefaults[id(screenshot)]321 except KeyError:322 raise KeyError('screenshot "%s" does not have findTextDefaults. '323 'If OcrEngine.addScreenshot() is overridden, it '324 '*must* call parent\'s addScreenshot.' % (screenshot.filename(),))325 def _removeScreenshot(self, screenshot):326 pass327 def setFindTextDefaults(self, **findTextDefaults):328 return self._setFindTextDefaults(findTextDefaults, screenshot=None)329 def setScreenshotFindTextDefaults(self, screenshot, **findTextDefaults):330 return self._setFindTextDefaults(findTextDefaults, screenshot=screenshot)331 def _setFindTextDefaults(self, defaults, screenshot=None):332 """333 Set default values for optional arguments for findText().334 Parameters:335 defaults (dictionary)336 Default keyword arguments and their values.337 screenshot (optional, fmbtgti.Screenshot instance)338 Use the defaults for findText on this screenshot. If339 the defaults are None, make them default for all340 screenshots. Screenshot-specific defaults override341 engine default.342 """343 if screenshot == None:344 self._findTextDefaults.update(defaults)345 else:346 ssid = id(screenshot)347 if not ssid in self._ssFindTextDefaults:348 self._ssFindTextDefaults[ssid] = self._findTextDefaults.copy()349 self._ssFindTextDefaults[ssid].update(defaults)350 def findTextDefaults(self, screenshot=None):351 if screenshot == None:352 return self._findTextDefaults353 elif id(screenshot) in self._ssFindTextDefaults:354 return self._ssFindTextDefaults[id(screenshot)]355 else:356 return None357 def _findTextArgNames(self):358 """359 Returns names of optional findText arguments.360 """361 return inspect.getargspec(self._findText).args[3:]362 def __ocrArgs(self, screenshot, **priorityArgs):363 ocrArgs = {}364 ocrArgs.update(self._findTextDefaults)365 ssId = id(screenshot)366 if ssId in self._ssFindTextDefaults:367 ocrArgs.update(self._ssFindTextDefaults[ssId])368 ocrArgs.update(priorityArgs)369 return ocrArgs370 def findText(self, screenshot, text, **kwargs):371 """372 Return list of fmbtgti.GUIItems that match to text.373 """374 ocrArgs = self.__ocrArgs(screenshot, **kwargs)375 return self._findText(screenshot, text, **ocrArgs)376 def _findText(self, screenshot, text, **kwargs):377 """378 Find appearances of text from the screenshot.379 Parameters:380 screenshot (fmbtgti.Screenshot)381 Screenshot from which text is to be searched382 for. Use Screenshot.filename() to get the filename.383 text (string)384 text to be searched for.385 other arguments (engine specific)386 kwargs contain keyword arguments given to387 findText(screenshot, text, ...), already extended388 first with screenshot-specific findTextDefaults, then...

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