查看appPackage和appActivity方法:

1.先在cmd命令行输入  adb logcat ActivityManager:I *:s

2.点击虚拟机启动app即可查看,/前是appPackage,/后是appActivity

Appium+python启动虚拟机上的app-LMLPHP

其他方法见:https://blog.csdn.net/xl_lx/article/details/78717917

代码:

# -*- coding:UTF-8 -*-
from appium import webdriver
import time
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['platformVersion'] = '6.0'
desired_caps['appPackage'] = 'com.netease.cloudmusic'
desired_caps['appActivity'] = '.activity.LoadingActivity'
wd = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
wd.find_element_by_id("com.netease.cloudmusic:id/arc").click()
wd.find_element_by_id("com.netease.cloudmusic:id/bw4").click()
wd.find_element_by_id("com.android.packageinstaller:id/permission_allow_button").click()
wd.find_element_by_id("com.android.packageinstaller:id/permission_allow_button").click()
time.sleep(10) # 睡眠10S等APP启动完成
05-12 07:34