【AirTest脚本】使用shell操作Android开发者选项

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录


正文

有些设置懒得去手机上点了,直接使用AirTest脚本使用shell操作android开发者选项,打开显示轨迹,显示坐标等选项。

代码里的开关统一为开或者关,如不需要自行修改

代码如下(示例):

# -*- encoding=utf8 -*-
__author__ = "x.j"

import re
from airtest.core.api import *

auto_setup(__file__)
# 列表
# s = shell("settings list system")
# print(s)

# 0|关 1|开
switch = 0

D:\AirtestIDE-win-1.2.17\AirtestIDE\airtest\core\android\cap_methods\adbcap.py:10: UserWarning: Currently using ADB screenshots, the efficiency may be very low. warnings.warn("Currently using ADB screenshots, the efficiency may be very low.") [15:35:46][DEBUG]<airtest.core.android.adb> C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 6D6T45N7WWH6JRAU shell screencap -p queue size is: 10 Traceback (most recent call last): File "app\plugins\devicepool\main_window.py", line 83, in _add_device_view File "app\plugins\devicepool\main_window.py", line 116, in _change_current_view File "app\plugins\devicepool\android\view.py", line 353, in turn_on File "app\plugins\devicepool\android\device.py", line 291, in start_push_flow File "airtest\core\android\android.py", line 239, in screen_proxy ori_function=lambda: self.display_info) File "airtest\core\android\cap_methods\screen_proxy.py", line 101, in auto_setup if cls.check_frame(screen): File "airtest\core\android\cap_methods\screen_proxy.py", line 53, in check_frame cap_method.get_frame() File "airtest\core\android\cap_methods\base_cap.py", line 28, in get_frame return self.get_frame_from_stream() File "airtest\core\android\cap_methods\adbcap.py", line 11, in get_frame_from_stream return self.adb.snapshot() File "airtest\core\android\adb.py", line 831, in snapshot raw = self.cmd('shell screencap -p', ensure_unicode=False) File "airtest\core\android\adb.py", line 234, in cmd raise DeviceConnectionError(stderr) airtest.core.error.DeviceConnectionError: b"error: device '6D6T45N7WWH6JRAU' not found\r\n" Sentry responded with an error [15:35:46][DEBUG]<airtest.core.android.rotation> orientationWatcher has ended [15:35:55][DEBUG]<airtest.core.android.adb> C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 6D6T45N7WWH6JRAU shell input keyevent HOME Traceback (most recent call last): File "airtest\core\android\adb.py", line 413, in shell out = self.raw_shell(cmd) File "airtest\core\android\adb.py", line 371, in raw_shell out = self.cmd(cmds, ensure_unicode=False) File "airtest\core\android\adb.py", line 236, in cmd raise AdbError(stdout, stderr) airtest.core.error.AdbError: stdout[b''] stderr[b'error: device offline\r\n'] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "app\plugins\devicepool\android\device.py", line 329, in operate_button File "airtest\core\android\android.py", line 519, in keyevent self.adb.keyevent(keyname) File "airtest\core\android\adb.py", line 430, in keyevent self.shell(["input", "keyevent", keyname.upper()]) File "airtest\core\android\adb.py", line 415, in shell raise AdbShellError(err.stdout, err.stderr) airtest.core.error.AdbShellError: stdout[b''] stderr[b'error: device offline\r\n']
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值