How to use test_auto_setup method in Airtest

Best Python code snippet using Airtest

test_connect.py

Source:test_connect.py Github

copy

Full Screen

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")...

Full Screen

Full Screen

test_touch_proxy.py

Source:test_touch_proxy.py Github

copy

Full Screen

...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):...

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 Airtest 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