1. 大致流程
+ 程序(Python):打开 QQ 音乐,点击一系列接收按键,进入搜索音乐界面,输入『Paradise』,播放第一首音乐。
2. Python 脚本如下
from appium import webdriver
import time
desired_caps = {}
desired_caps['platformName'] = 'Android'
# adb shell getprop ro.build.version.release 获得版本号
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'com.tencent.qqmusic'
# adb shell dumpsys activity activities | grep "realActivity" 获得 appActivity
desired_caps['appActivity'] = '.activity.AppStarterActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# 一系列点击
# page1 SD
driver.find_element_by_id('com.tencent.qqmusic:id/y3').click()
time.sleep(1)
# page2 电话 com.android.packageinstaller:id/permission_allow_button
driver.find_element_by_id('com.android.packageinstaller:id/permission_allow_button').click()
# driver.findElementByXPath("//android.widget.Button[@text='始终允许']").click();
time.sleep(1)
# page3
driver.find_element_by_id('com.android.packageinstaller:id/permission_allow_button').click()
time.sleep(1)
# page4 com.tencent.qqmusic:id/v3 跳过
driver.find_element_by_id('com.tencent.qqmusic:id/v3').click()
time.sleep(1)
# page5 取消登录
driver.find_element_by_id('com.tencent.qqmusic:id/lh').click()
time.sleep(1)
# page6 点击收缩
driver.find_element_by_id('com.tencent.qqmusic:id/t3').click()
time.sleep(1)
# page7
driver.find_element_by_id('com.tencent.qqmusic:id/a7j').click()
search_box = driver.find_element_by_id('com.tencent.qqmusic:id/a7j')
search_box.click()
search_box.send_keys('paradise') # 输入检索的歌名,不支持中文(好像?)
time.sleep(2)
# com.tencent.qqmusic:id/cb3
driver.find_element_by_id('com.tencent.qqmusic:id/cb3').click()
time.sleep(1)
# com.tencent.qqmusic:id/a55
driver.find_element_by_id('com.tencent.qqmusic:id/a55').click()
time.sleep(1)
3. 程序运行视频(录屏)
- 运行手机录屏,点击观看
原文地址:https://www.cnblogs.com/juking/p/9539239.html
时间: 2024-10-03 02:04:11