码迷,mamicode.com
首页 > 移动开发 > 详细

Appium + Python 测试 QQ 音乐 APP的一段简单脚本

时间:2018-08-26 22:33:53      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:cap   driver   获得   path   收缩   version   接收   iss   运行   

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. 程序运行视频(录屏)

Appium + Python 测试 QQ 音乐 APP的一段简单脚本

标签:cap   driver   获得   path   收缩   version   接收   iss   运行   

原文地址:https://www.cnblogs.com/juking/p/9539239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!