Best Python code snippet using fMBT_python
fmbtgti.py
Source:fmbtgti.py
...1437 if distance > 1.0: distance = float(distance) / distToEdge1438 x2 = int(x + math.cos(dirRad) * distToEdge * distance)1439 y2 = int(y - math.sin(dirRad) * distToEdge * distance)1440 return self.drag((x, y), (x2, y2), **dragArgs)1441 def swipeBitmap(self, bitmap, direction, distance=1.0, **dragAndOirArgs):1442 """1443 swipe starting from bitmap to given direction.1444 Parameters:1445 bitmap (string)1446 bitmap from which swipe starts1447 direction, distance1448 refer to swipe documentation.1449 startPos1450 refer to swipeItem documentation.1451 optical image recognition arguments (optional)1452 refer to help(obj.oirEngine()).1453 delayBeforeMoves, delayBetweenMoves, delayAfterMoves,1454 movePoints1455 refer to drag documentation....
fmbtandroid.py
Source:fmbtandroid.py
...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 in87mydevice.ini.88import fmbtandroid89d = fmbtandroid.Device(iniFile=file("/tmp/mydevice.ini"))90d.refreshScreenshot()91d.swipeBitmap("lock.png", "east")92* * *93Execute a shell command on Android device, show exit status, standard94output and standard error:95import fmbtandroid96status, out, err = fmbtandroid.Device().shellSOE("mkdir /proc/foo")97print 'status: %s, stdout: "%s", stderr: "%s"' % (status, out, err)98* * *99Enable extensive logging with screenshots and highlighted content:100import fmbtandroid, time101d = fmbtandroid.Device()102d.enableVisualLog("example.html")103d.pressHome(); time.sleep(1)104d.refreshScreenshot()105d.tapOcrText("Google"); time.sleep(1)...
fmbttizen.py
Source:fmbttizen.py
...32d.pressHome()33time.sleep(1)34d.refreshScreenshot()35if d.verifyBitmap("lock.png"):36 d.swipeBitmap("lock.png", "east") # open screenlock37 time.sleep(1)38 d.pressHome()39if d.waitOcrText("Settings"):40 d.tapOcrText("Settings", tapPos=(0.5, -1))41"""42import atexit43import base6444import cPickle45import commands46import math47import shlex48import subprocess49import os50import Queue...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!