Airtest
Airtest copied to clipboard
是否可以更改默认的adb路径
我想做成和gui结合的方式 打包 用户只需要打开exe文件就可以使用了 目前看到每次运行的时候是调用ide自带的adb 是否可以用指定的adb呢 怎么用呢?
请补充描述下是如何打包的?
就是用pyinstaller 打包 用python os 模块 os.system(" Python36\Scripts\airtest.exe run testStarApp.py --device Android:///0e1b9aa59905 ") 会调用默认的adb路径 如果没有的话就运行不了 是否可以引用我当前目录下的adb路径呢 调用的时候就直接用指定的adb
我们没有试过这样打包airtest来运行脚本,目前airtest是会强制使用默认目录下的adb.exe的 在AirtestIDE打包之后,也会额外按照airtest的目录路径,把那些静态资源文件拷贝一份放进打包后的文件夹里(目前是直接把所有的airtest源码都拷贝了一份过去,但是以前版本的IDE是只打包那些静态资源文件的,但是会保留所有的目录结构) 你们也可以考虑在目录下按照airtest原来的目录结构,放一个adb.exe在static/android目录里
我们的项目在调用airtest的API前加了个判断,如果本地已经安装了adb,则使用本地安装的
def _set_adb_path():
system = platform.system()
machine = platform.machine()
adb_index = '{}-{}'.format(system, machine)
if adb_index not in DEFAULT_ADB_PATH:
adb_index = system
# overwrite uiautomator adb
if "ANDROID_HOME" in os.environ:
sdk_path = os.environ["ANDROID_HOME"]
if "Windows" == adb_index:
adb_path = os.path.join(sdk_path, 'platform-tools', 'adb.exe')
else:
adb_path = os.path.join(sdk_path, 'platform-tools', 'adb')
if os.path.exists(adb_path):
DEFAULT_ADB_PATH[adb_index] = adb_path
print('set adb path to {0}'.format(DEFAULT_ADB_PATH[adb_index]))
希望可以自定义 adb 路径或者默认优先使用 PATH 路径下的 adb。 airtest 里面的 adb 版本和开发环境中 adb 不一致,造成冲突, 开一个会把另一个 kill 掉。 比如开了 android studio, aritest 就连不上。 开了 airtest,就不能用 android studio 里面的 adb
遇到同样的问题,用pyinstaller 打包,运行Airtest的 python时报错
[13:37:44][DEBUG]<airtest.core.android.adb> C:\Users{username}\AppData\Local\Temp_MEI314882\airtest\core\android\static\adb\windows\adb.exe devices [WinError 2] The system cannot find the file specified
我们的项目在调用airtest的API前加了个判断,如果本地已经安装了adb,则使用本地安装的
def _set_adb_path(): system = platform.system() machine = platform.machine() adb_index = '{}-{}'.format(system, machine) if adb_index not in DEFAULT_ADB_PATH: adb_index = system # overwrite uiautomator adb if "ANDROID_HOME" in os.environ: sdk_path = os.environ["ANDROID_HOME"] if "Windows" == adb_index: adb_path = os.path.join(sdk_path, 'platform-tools', 'adb.exe') else: adb_path = os.path.join(sdk_path, 'platform-tools', 'adb') if os.path.exists(adb_path): DEFAULT_ADB_PATH[adb_index] = adb_path print('set adb path to {0}'.format(DEFAULT_ADB_PATH[adb_index]))
我用了这个还是引用默认的Airtest adb目录,是使用的地方不对,我看代码也执行了
PS E:\learnProject\SmartRobot\Test\dist> .\AirtestAutomation.exe b set adb path to D:\SDK\platform-tools\adb.exe E:\learnProject\SmartRobot\Test\dist\AirtestAutomation.exe ['E:\learnProject\SmartRobot\Test\dist\AirtestAutomation.exe', 'b'] [13:52:37][DEBUG]<airtest.core.android.adb> C:\Users\lijinxin\AppData\Local\Temp_MEI209562\airtest\core\android\static\adb\windows\adb.exe devices [WinError 2] The system cannot find the file specified PS E:\learnProject\SmartRobot\Test\dist>