zoukankan      html  css  js  c++  java
  • Appium + Python 测试 QQ 音乐 APP的一段简单脚本

    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'
    #  adb shell dumpsys package packages | grep  "Package ["     获取已安装的 appPackage Name
    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. 程序运行视频(录屏)

  • 相关阅读:
    双阈值对抗数据抖动
    ES6 初体验 —— gulp+Babel 搭建ES6环境
    chrome 浏览器插件开发(二)—— 通信 获取页面变量 编写chrome插件专用的库
    邮件模板——开发篇
    Java-eclipse导入jar包
    php小程序-文章发布系统(mvc框架)
    php小程序-文章发布系统
    php小项目-web在线文件管理器
    杂论—电脑远程控制
    PHP-正则表达式
  • 原文地址:https://www.cnblogs.com/juking/p/9539239.html
Copyright © 2011-2022 走看看