How to use waitAnyBitmap method in fMBT

Best Python code snippet using fMBT_python

fmbtgti.py

Source:fmbtgti.py Github

copy

Full Screen

...1694 refreshFunc()1695 if waitFunc(*waitFuncArgs, **waitFuncKwargs):1696 return True1697 return False1698 def waitAnyBitmap(self, listOfBitmaps, **waitAndOirArgs):1699 """1700 Wait until any of given bitmaps appears on screen.1701 Parameters:1702 listOfBitmaps (list of strings):1703 list of bitmaps (filenames) to be waited for.1704 optical image recognition arguments (optional)1705 refer to help(obj.oirEngine()).1706 waitTime, pollDelay (float, optional):1707 refer to wait documentation.1708 Returns list of bitmaps appearing in the first screenshot that1709 contains at least one of the bitmaps. If none of the bitmaps1710 appear within the time limit, returns empty list.1711 If the bitmap is not found from most recently refreshed1712 screenshot, waitAnyBitmap updates the screenshot.1713 """1714 if listOfBitmaps == []: return []1715 if not self._lastScreenshot: self.refreshScreenshot()1716 waitArgs, rest = _takeWaitArgs(waitAndOirArgs)1717 oirArgs, _ = _takeOirArgs(self._lastScreenshot, rest, thatsAll=True)1718 foundBitmaps = []1719 def observe():1720 for bitmap in listOfBitmaps:1721 if self._lastScreenshot.findItemsByBitmap(bitmap, **oirArgs):1722 foundBitmaps.append(bitmap)1723 return foundBitmaps != []1724 self.wait(self.refreshScreenshot, observe, **waitArgs)1725 return foundBitmaps1726 def waitAnyOcrText(self, listOfTexts, **waitAndOcrArgs):1727 """1728 Wait until OCR recognizes any of texts on the screen.1729 Parameters:1730 listOfTexts (list of string):1731 texts to be waited for.1732 waitTime, pollDelay (float, optional):1733 refer to wait documentation.1734 OCR engine specific arguments1735 refer to help(obj.ocrEngine())1736 Returns list of texts that appeared in the first screenshot1737 that contains at least one of the texts. If none of the texts1738 appear within the time limit, returns empty list.1739 If any of texts is not found from most recently refreshed1740 screenshot, waitAnyOcrText updates the screenshot.1741 """1742 if listOfTexts == []: return []1743 if not self._lastScreenshot: self.refreshScreenshot()1744 waitArgs, rest = _takeWaitArgs(waitAndOcrArgs)1745 ocrArgs, _ = _takeOcrArgs(self._lastScreenshot, rest, thatsAll=True)1746 foundTexts = []1747 def observe():1748 for text in listOfTexts:1749 if self.verifyOcrText(text, **ocrArgs):1750 foundTexts.append(text)1751 return foundTexts != []1752 self.wait(self.refreshScreenshot, observe, **waitArgs)1753 return foundTexts1754 def waitBitmap(self, bitmap, **waitAndOirArgs):1755 """1756 Wait until bitmap appears on screen.1757 Parameters:1758 bitmap (string):1759 filename of the bitmap to be waited for.1760 optical image recognition arguments (optional)1761 refer to help(obj.oirEngine()).1762 waitTime, pollDelay (float, optional):1763 refer to wait documentation.1764 Returns True if bitmap appeared within given time limit,1765 otherwise False.1766 If the bitmap is not found from most recently refreshed1767 screenshot, waitBitmap updates the screenshot.1768 """1769 return self.waitAnyBitmap([bitmap], **waitAndOirArgs) != []1770 def waitOcrText(self, text, **waitAndOcrArgs):1771 """1772 Wait until OCR detects text on the screen.1773 Parameters:1774 text (string):1775 text to be waited for.1776 waitTime, pollDelay (float, optional):1777 refer to wait documentation.1778 OCR engine specific arguments1779 refer to help(obj.ocrEngine())1780 Returns True if the text appeared within given time limit,1781 otherwise False.1782 If the text is not found from most recently refreshed1783 screenshot, waitOcrText updates the screenshot....

Full Screen

Full Screen

fmbtandroid.py

Source:fmbtandroid.py Github

copy

Full Screen

...63import time64d = fmbtandroid.Device()65d.pressHome()66time.sleep(1)67whatISee = d.waitAnyBitmap(["lockscreen-lock.png", "home-appgrid.png"])68if "lockscreen-lock.png" in whatISee:69 d.swipeBitmap("lockscreen-lock.png", "east")70 time.sleep(1)71 d.pressHome()72 whatISee = d.waitAnyBitmap(["home-appgrid.png"])73assert "home-appgrid.png" in whatISee, "Cannot find appgrid bitmap at"74d.tapBitmap("home-appgrid.png")75* * *76Save generated device ini for modifications77import fmbtandroid78file("/tmp/mydevice.ini", "w").write(fmbtandroid.Device().dumpIni())79* * *80Connect to device based on an ini file81import fmbtandroid82d = fmbtandroid.Device(iniFile=file("/tmp/mydevice.ini"))83d.pressHome()84* * *85Open screenlock by swiping lock.png bitmap on the display to the86east. The lock.png file needs to be in bitmapPath defined in...

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