appium +python 新手入门教程
环境准备
- appium 安装
环境变量配置:
Appium_Home:C:\Program Files (x86)\Appium
Path:C:\Program Files (x86)\Appium\node_modules\.bin
检查是否安装成功:appium-doctor
- android-sdk安装
(没有java环境的要先安装jdk)
通过官方地址下载安装sdk:http://developer.android.com/sdk/index.html
环境变量配置:
ANDROID_HOME :D:\android\android-sdk-windows
PATH:;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
- python环境搭建
如果要下载帮助文件:Download Windows help file
如果要下载基于网页的安装程序: Download Windows x86-64 web-based installer
如果要下载可执行的安装程序: Download Windows x86-64 executable installer
如果要下载python程序的压缩包: Download Windows x86-64 embeddable zip file
如果要下载基于网页的安装程序: Download Windows x86-64 web-based installer
如果要下载可执行的安装程序: Download Windows x86-64 executable installer
如果要下载python程序的压缩包: Download Windows x86-64 embeddable zip file
环境变量搭建:Path:D:\python\python32
- selenium安装(依赖)
- appium-python-client安装
pip search appium-python-client
pip install appium-python-client
pip show appium-python-client
测试准备
- android手机连接PC
- 手机开启开发模式和usb调试
手机元素抓取
- 通过uiautomator定位手机元素
C:\Program Files\android-sdk-windows\tools\uiautomatorviewer.bat
脚本编写
- desired_caps是一个字典,用于在appium server 与手机端建立会话关系时,手机端需要告诉服务端设备相关的一些参数,根据这些参数服务端可以做出相应的处理。
desired_caps = {}
desired_caps['platformName'] = 'Android' //运行系统
desired_caps['platformVersion']='6.0.1' //运行版本
desired_caps['deviceName']='d19fc6b1' //设备名称
desired_caps['appPackage']='com.rhfund' //包名
desired_caps['appActivity']='.activity.SplashActivity' //启动入口
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
//连接到appium server
- demo讲解
- demo运行
欢迎交流
版权声明:本文为博主原创文章,转载请注明出处。
版权声明:本文为博主原创文章,转载请注明出处。