ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
- 启动夜神模拟器设备 ``` 打开cmd命令行,进入夜神安装目录,执行如下命令: cd D:\Program Files (x86)\nox\bin nox_adb.exe connect 127.0.0.1:62001 在cmd命令行中,输入:adb devices查看 存在:127.0.0.1:62001 device 即为成功! adb devices ``` - 安装测试app 将测试app.apk安装包拖到夜神模拟器即可安装测试app。 - 运行与使用Appium ![](https://box.kancloud.cn/c39530973546b2f588a20435c72f70b6_650x600.jpg) - 编写Appium自动化测试脚本 ``` from appium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time desired_caps = {} desired_caps['platformName'] = "Android" # 声明是ios还是Android系统 desired_caps['platformVersion'] = '4.4.2' # Android内核版本号,可以在夜神模拟器设置中查看 desired_caps['deviceName'] = '127.0.0.1:62001' # 连接的设备名称 desired_caps['appPackage'] = 'com.tencent.android.qqdownloader' # apk的包名 desired_caps['appActivity'] = 'com.tencent.pangu.link.SplashActivity' # apk的launcherActivity driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) # 建立 session time.sleep(5) ``` - 获取apk包名和launcherActivity ``` 把测试app.apk放在D:\test\文件夹下 打开cmd命令行,输入:aapt dump badging D:\test\app.apk(apk的全名,比如:手机淘宝.apk) 这里可以看到apk包名为:com.taobao.taobao ``` ![](https://box.kancloud.cn/7b7d0e177d831746a11a3bd3513d60ad_677x442.jpg) - 获取launcherActivity ![](https://box.kancloud.cn/1eb891006814cca83fb08475d7ec8e12_677x442.jpg) - 获取apk元素 ![](https://box.kancloud.cn/c96fc9fdcd54fe81560b6ae9e0b63a55_650x600.jpg) ![](https://box.kancloud.cn/df05f47c6ee386735712db2d3e01c03f_920x570.jpg) ![](https://box.kancloud.cn/d31f9db2a831dfe644b3a91dd0425486_1366x728.jpg)