Appium 环境搭建
一、下载并安装appium客户端(勿装1.15.1版本,1.15.1版本很多坑)进入appium官网http://appium.io/下载版本,将下载好的版本按照步骤进行安装Appium-Python-Client第三方包pip3 install Appium-Python-Client -i https://pypi.tuna.tsinghua.edu.cn/simple二、配置jdk及Andr
一、下载并安装appium客户端(勿装1.15.1版本,1.15.1版本很多坑)
进入appium官网http://appium.io/下载版本,将下载好的版本按照步骤进行安装
Appium-Python-Client第三方包
pip3 install Appium-Python-Client -i https://pypi.tuna.tsinghua.edu.cn/simple
二、配置jdk及Android sdk环境
2.1、jdk8下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
按照步骤进行安装jdk
2.2、Android SDK下载地址:http://dl.google.com/android/android-sdk_r23.0.2-windows.zip
2.2.1、下载SDK后解压文件,运行SDK Manager安装platform-tools
2.2.2、配置Android环境变量
1)、新增系统变量,变量名:ANDROID_HOME,变量值:Android SDK存放根目录
2)、在系统变量path中新增变量:;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
三、appium启动Android app
android (vivo x21) desired capabilities:
{ “appPackage”: “com.lumiunited.aqarahome”, “appActivity”: “com.lumiunited.aqara.main.SplashActivity”, “noReset”: “true”, “platformVersion”: “9”, “deviceName”: “android”, “platformName”: “Android” }
直接套用会使用就可以
import time
from appium import webdriver
desired_caps = {}
desired_caps[‘platformName’] = ‘Android’ # 打开什么平台的app,固定的 > 启动安卓平台
desired_caps[‘platformVersion’] = ‘6.0.1’ # 安卓系统的版本号:adb shell getprop ro.build.version.release
desired_caps[‘deviceName’] = ‘P10’ # 手机/模拟器的型号:adb shell getprop ro.product.model
desired_caps[‘appPackage’] = ‘io.appium.android.apis’ # app的名字:
# 安卓8.1之前:adb shell dumpsys activity | findstr “mFocusedActivity”
# 安卓8.1之后:adb shell dumpsys activity | findstr “mResume”
desired_caps[‘appActivity’] = ‘.ApiDemos’ # 同上↑
desired_caps[‘unicodeKeyboard’] = True # 为了支持中文
desired_caps[‘resetKeyboard’] = True # 设置成appium自带的键盘
desired_caps[‘noReset’] = True # 使用app的缓存
去打开app,并且返回当前app的操作对象
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
四、appium 启动iOS app
4.1、iOS真机安装webdriveragent(appium自带WDA,WDA路径见配置环境中问题记录2)
1)、终端进入目录:/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/webdriveragent
2)、执行脚本
命令行终端到wda根目录下, 运行./Scripts/bootstrap.sh
3)、打开项目,配置开发者证书,WebDriverAgentRunner项目build setting修改bundle Id为唯一标识(如com.lumi.WebDriverAgentRunner),product-》test运行
4)、浏览器输入http://localhost:8100/status,可显示结果数据,例如下:
{ “value” : { “message” : “WebDriverAgent is ready to accept commands”, “state” : “success”, “os” : { “name” : “iOS”, “version” : “13.4.1”, “sdkVersion” : “13.4” }, “ios” : { “simulatorVersion” : “13.4.1”, “ip” : “10.0.100.19” }, “ready” : true, “build” : { “time” : “May 21 2020 18:36:31”, “productBundleIdentifier” : “com.facebook.WebDriverAgentRunner” } }, “sessionId” : “B9BE0798-C334-47BE-AFDF-F99D12CC036D” }
WebdriverAgent环境配置成功
5)、启动appium,配置desired capability为:
{ “bundleId”: “com.lumiunited.pre.homekit”, “automationName”: “XCUITest”, “platformVersion”: “13.4.1”, “deviceName”: “iphone”, “platformName”: “iOS”, “udid”: “2e6939b70da40972c17971831a7ed4e43087b8e9” }
五、配置环境中问题记录:
1、appium配置Android desired capabilities 启动时提示The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb(电脑已配置Android SDK环境)
解决方案:
appium-》Configurations配置Android sdk路径,重启appium可正常启动Aqara Home app
2、appium 1.15.1版本webdriver路径为:/Applications/Appium.app/Contents/Resources/app/node_modules/appium-webdriveragent
appium通用路径为:/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/webdriveragent
3、执行脚本时提示 ./Scripts/bootstrap.sh提示ERROR in ./js/app.js Module parse failed:/app.js Unexpected token错误
解决方案:1、修改Inspector下webpack.config.js文件
2、去掉babel-loader配置后的,“exclude: /node_modules/”
3、删除Inspector下node_modules文件夹
4、重新执行 “sh ./Scripts/bootstrap.sh”
4、运行时提示’assign’ property of object type may become a dangling reference; consider using ‘unsafe_unretained’
解决方案:我们在报错出双击,进入到报错代码处,将assign改为strong后再次build
更多推荐
所有评论(0)