Best Python code snippet using Airtest
test_android.py
Source:test_android.py
...58# w = d.watcher()59# w.wait('xxx.png', 5).click(x,y).expect('xxx.png', 3) --> Exception means fail60# w.wait(1).click(x,y)61# w.exists('xxx.png')62def test_minicap():63 from atx.drivers.android_minicap import AndroidDeviceMinicap64 cv2.namedWindow("preview")65 d = AndroidDeviceMinicap()66 while True:67 try:68 h, w = d._screen.shape[:2]69 img = cv2.resize(d._screen, (w/2, h/2))70 cv2.imshow('preview', img)71 key = cv2.waitKey(1)72 if key == 100: # d for dump73 filename = time.strftime('%Y%m%d%H%M%S.png')74 cv2.imwrite(filename, d._screen)75 except KeyboardInterrupt:76 break77 cv2.destroyWindow('preview')78def test_minitouch():79 from atx.drivers.android_minicap import SubAdb80 81 adb = SubAdb()82 adb.start_minitouch()83 adb.home()84 for pos in ((100, 200), (1000, 200), ):#(100, 1900), (1000, 1900)):85 adb.touch(*pos)86 time.sleep(1)87 for i in range(10):88 adb.swipe(100, 100, 500, 100)89 time.sleep(1)90 adb.swipe(500, 100, 100, 100)91 time.sleep(1)92 return adb93if __name__ == '__main__':94 # test_screenshot()95 test_minicap()...
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!!