How to use _set_cmd_options method in Airtest

Best Python code snippet using Airtest

adb.py

Source:adb.py Github

copy

Full Screen

...21 """adb object class"""22 def __init__(self, device_id: str = None, adb_path: str = None, host='127.0.0.1', port=5037):23 self.device_id = device_id24 self.adb_path = adb_path or self.builtin_adb_path()25 self._set_cmd_options(host, port)26 self.connect()27 self._event_path = None # event信息28 self._display_info = {}29 self._line_breaker = None30 # 截图文件名字31 self._cap_name = ADB_CAP_NAME_RAW.format(self.get_device_id(decode=True))32 # 截图在手机上的路径33 self._cap_local_path = ADB_CAP_LOCAL_PATH.format(self._cap_name)34 # 截图png存放到工程的路径35 self._cap_remote_path = ADB_CAP_REMOTE_PATH.format(self.get_device_id(decode=True))36 # raw临时文件存放到工程的路径37 self._cap_raw_remote_path = ADB_CAP_REMOTE_RAW_PATH.format(self._cap_name)38 # 已经使用的端口39 self._sdk_version = self.sdk_version()40 @staticmethod41 def builtin_adb_path() -> str:42 """adb路径"""43 system = platform.system()44 machine = platform.machine()45 adb_path = DEFAULT_ADB_PATH.get('{}-{}'.format(system, machine))46 if not adb_path:47 adb_path = DEFAULT_ADB_PATH.get(system)48 if not adb_path:49 raise RuntimeError("No adb executable supports this platform({}-{}).".format(system, machine))50 # overwrite uiautomator adb51 if "ANDROID_HOME" in os.environ:52 del os.environ["ANDROID_HOME"]53 return adb_path54 def _set_cmd_options(self, host: str, port: int):55 """56 设置adb服务器57 Args:58 host: adb路径59 port: adb端口号60 Returns:61 None62 """63 self.host = host64 self.port = port65 self.cmd_options = [self.adb_path]66 if self.host not in ("localhost", "127.0.0.1"):67 self.cmd_options += ['-H', self.host]68 if self.port != 5037:...

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