Best Python code snippet using Airtest
test_connect.py
Source:test_connect.py
1from airtest.core.api import auto_setup, connect_device, set_current, init_device2class Test_connect:3 #auto_setup æ¯ä¸ä¸ªç¨æ¥ åå§åç¯å¢ çæ¥å£ï¼å®æ¥å5个åæ°:4 #æ们å¯ä»¥è®¾ç½®å½åèæ¬æå¨çè·¯å¾ã æå®è¿è¡èæ¬çè®¾å¤ ã设置é»è®¤çlogè·¯å¾ã设置èæ¬ç¶è·¯å¾åæå®æªå¾ç²¾åº¦ï¼5 def test_auto_setup(self):6 # è¿æ¥æ¬æºé»è®¤ç«¯å£è¿çä¸å°è®¾å¤å·ä¸ºSJE5T17B17çææº7 auto_setup(__file__, devices=["Android://127.0.0.1:5037/SJE5T17B17"])8 ## è¿æ¥æ¬æºé»è®¤ç«¯å£è¿ç设å¤å·ä¸º123å456ç两å°ææº9 auto_setup(__file__, devices=["Android://127.0.0.1:5037/123", "Android://127.0.0.1:5037/456"])10 def test_connect_device(self):11 # è¿ä¸ç¬¬ä¸å°ææº12 dev1 = connect_device("Android://127.0.0.1:5037/serialno1")13 # è¿ä¸ç¬¬äºå°ææº14 dev2 = connect_device("Android://127.0.0.1:5037/serialno2")15 # åæ¢å½åæä½çææºå°åºåå·ä¸ºserialno1çææº16 set_current("serialno1")17 def test_init_device(self):18 #init_device æ¥å£åªéè¦ä¼ å
¥ 设å¤å¹³å°å设å¤çuuid å³å¯ï¼åæ°è¯¦æ
å¯ä»¥æ¥çä¸å¾ï¼19 init_device(platform="Android", uuid="SJE5T17B17")...
test_touch_proxy.py
Source:test_touch_proxy.py
...8 @classmethod9 def setUpClass(cls):10 cls.dev = Android()11 cls.dev.ori_method = "ADBORI"12 def test_auto_setup(self):13 touch_proxy = TouchProxy.auto_setup(self.dev.adb,14 ori_transformer=self.dev._touch_point_by_orientation,15 size_info=None,16 input_event=None)17 touch_proxy.touch((100, 100))18 touch_proxy = TouchProxy.auto_setup(self.dev.adb,19 default_method="MINITOUCH",20 ori_transformer=self.dev._touch_point_by_orientation,21 size_info=self.dev.display_info,22 input_event=self.dev.input_event)23 touch_proxy.touch((100, 100))24 def test_touch_method(self):25 self.assertIn(self.dev.touch_method, TouchProxy.TOUCH_METHODS.keys())26 def test_get_deprecated_var(self):...
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!!