【发布时间】:2021-10-20 10:57:04
【问题描述】:
我已经查阅了有关该主题的几个主题,但我没有看到任何与直接使用 ppadb 命令在设备上启动应用程序相关的内容。
我设法完成了这段代码:
import ppadb
import subprocess
from ppadb.client import Client as AdbClient
# Create the connect functiun
def connect():
client = AdbClient(host='localhost', port=5037)
devices = client.devices()
for device in devices:
print (device.serial)
if len(devices) == 0:
print('no device connected')
quit()
phone = devices[0]
print (f'connected to {phone.serial}')
return phone, client
if __name__ == '__main__':
phone, client = connect()
import time
time.sleep(5)
# How to print each app on the emulator
list = phone.list_packages()
for truc in list:
print(truc)
# Launch the desired app through phone.shell using the package name
phone.shell(????????????????)
从那里,我可以访问每个应用程序包 (com.package.name)。我想通过phone.shell() 命令启动它,但我无法访问正确的语法。
我可以执行敲击或按键事件,而且效果很好,但我想确保我的代码不会因位置的任何变化而受到干扰。
【问题讨论】: