Appium 最新版 Appium mac os cataline xcode 13.1 WDA 爬坑记和启动 Appium inspector

云曦 · 2020年01月05日 · 最后由 IsaacCotton 回复于 2020年09月23日 · 5889 次阅读

Appium 版本 desktop 1.15.1
Mac OS 版本 cataline 10.15.2
Xcode 版本 13.1
最近需要调试 ios 自动化框架,根据以往老版本的经验,步骤是先安装 appium,我这边同时安装了 appium desktop 1.15.1 版本和 npm 安装了 appium 1.16.0 的版本,下面以 desktop 版本为例
首先常规步骤是:
1.安装 appium, 可以通过以下链接下载:
https://github.com/appium/appium-desktop/releases/tag/v1.15.1
注意:如果安装的是 desktop 版本的 appium 安装如果提示 不能打开软件提示无法打开 “appium”,因为 Apple 无法检查其是否包含恶意软件,则命令行中输入如下:
sudo xattr -rd com.apple.quarantine /Applications/Appium.app
mac os cataline 版本安全限制更严格了,对普通用户来说是件好事,但是对开发者来说增添了很对麻烦

  1. 安装 Carthage 我这里先是通过命令行安装的, brew install carthage 安装好后的版本是 0.31.2 Carthage 可以理解为在 xcodeproject 用来管理和自动下载和安装所有项目所需依赖包的一个工具,作用有点类似于 maven 当然,这里有坑,待会说

3.WDA
很多古老的教程会教你 appium 自带的 WDA 有问题,需要从 facebook 的 git project 上去下载一个进行配置和替换,其实现在新版的 appium 已经不需要,我就用的 appium 自带的 WDA,这个路径的话要看自己电脑了
我的 appium desktop 版本的路径是:/Applications/Appium.app/Contents/Resources/app/node_modules/appium-webdriveragent
appium 命令行启动版本的路径是: /usr/local/lib/node_modules/appium/node_modules/_appium-webdriveragent@2.5.0@appium-webdriveragent
根据你自己的安装路径用 find 搜索一下

然后用
sh ./Scripts/bootstrap.sh -d
这里坑就来了,

找不到可用的 simulator
可能是跟我的最新版的 xcode 有关
随后找到了 Carthage 的 github 看版本 当前我机器上的版本是 0.31.2 brew 安装不指定版本的话就会安装这个 stable 的版本,最新版本是 0.34.0,支持 xcode 10.0+,我是先卸载了当前的版本,然后下载最新版本的 pkg 文件
卸载 carthage: brew uninstall carthage --force
下载最新版本: https://github.com/Carthage/Carthage/releases
安装好后再切换到我 appium 的 WDA 路径下
cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium-webdriveragent
sh ./Scripts/bootstrap.sh -d
现在就不再报错了

4.配置 WDA

用 Xcode 打开 WDA, 这里有 WebDriverAgentLib 和 WebDriverAgentRunner, 在 targets 里找到这两个,打开 Signing & Capabilities,勾选 Automatic manage signing,并选择你的开发者账号,没有用个人账号也可以

改好后还有一个地方,WebAgentRunner 里的 bundle 不能重复,在 Build Setting 里找到 product bundle identifier 随便改一下

然后选好 Scheme 和 Desination

最后选择 Product -> Test,会启动相应的模拟器并在模拟器上安装 WebDriverAgent


在浏览器中输入 127.0.0.1:8100/status,可以看到 status 是 success

如果 destination 需要在机器中按照提示做相应的设置,这里就不多说了,此外还需要用 iproxy 进行一下端口转发:
$ brew install libimobiledevice --HEAD
$ iproxy 8100 8100

  1. 打开 Appium desktop 首先要找到机器的设备号,模拟器可以在 Xcode 中的 Window - > Devices and Simulators 中找到设备的 identifier 真机可以通过命令行 idevice_id -l 获取 得到安装的 app 及其信息,bundle 可以用用以下命令: $ ideviceinstaller -l

在启动的 Appium 中点击右上角的放大镜图标,会进入到 inspector 启动界面, 启动参数如下:

共收到 12 条回复 时间 点赞

赞一个!思路学习了

感谢分享,学习了!

请问下 appium 现在支持 electron 平台吗

很棒 学习了~

赞一个,等公司给我配 mac 了再细看


我的 inspector 页面获取不到页面元素,请问楼主遇到这样的情况了嘛?

池下 回复

是桌面应用吗?应该是不支持的,不过你可以考虑用 openCV 二次开发去实现,或者用 AirTest,这两个都是基于图像识别的

MLL 回复

真机还是模拟器?

9楼 已删除

Nice ! 感谢分享 !

云曦 回复

真机

云曦 回复

已经解决啦!我把 appium 升级后就好了。虽然 inspector 命令在编译 WDA 还是不能识别,但是 appium 已经可以正常运行了

我的是环境
Appium 版本 desktop 1.15.1
Mac OS 版本 cataline 10.15.4
Xcode 版本 11.5
现在 appium 可以给模拟器安装 webdriveragent,但是不停的安装卸载
现在是如下错误,希望得到楼主及时解惑

[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[XCUITest] xcodebuild exited with code '65' and signal 'null'
[BaseDriver] Event 'wdaStartFailed' logged at 1600840309265 (13:51:49 GMT+0800 (CST))
[XCUITest] Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
[XCUITest] xcodebuild error message:
[XCUITest]
[XCUITest] Quitting and uninstalling WebDriverAgent
[XCUITest] Shutting down sub-processes
[iOSSim] Building bundle path map
[iOSSim] The simulator has 'com.facebook.WebDriverAgentRunner.xctrunner' which have 'WebDriverAgentRunner-Runner' as their 'CFBundleName'
[XCUITest] Uninstalling WDAs: 'com.facebook.WebDriverAgentRunner.xctrunner'
[BaseDriver] Event 'wdaStartAttempted' logged at 1600840320878 (13:52:00 GMT+0800 (CST))
[XCUITest] Retrying WDA startup (2 of 2)
[XCUITest] Launching WebDriverAgent on the device
[WebDriverAgent] Fetching dependencies
[WebDriverAgent] Dependencies up-to-date
[XCUITest] Killing running processes 'xcodebuild.*9AB3D150-AD07-4905-9DC0-674C981B8434, 9AB3D150-AD07-4905-9DC0-674C981B8434.*XCTRunner' for the device 9AB3D150-AD07-4905-9DC0-674C981B8434...
[XCUITest] 'pgrep -ifn xcodebuild.*9AB3D150-AD07-4905-9DC0-674C981B8434' didn't detect any matching processes. Return code: 1
[XCUITest] 'pgrep -ifn 9AB3D150-AD07-4905-9DC0-674C981B8434.*XCTRunner' didn't detect any matching processes. Return code: 1
[XCUITest] Beginning test with command 'xcodebuild build-for-testing test-without-building -project /Applications/Appium.app/Contents/Resources/app/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=9AB3D150-AD07-4905-9DC0-674C981B8434 IPHONEOS_DEPLOYMENT_TARGET=13.5 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO' in directory '/Applications/Appium.app/Contents/Resources/app/node_modules/appium-webdriveragent'
[XCUITest] Output from xcodebuild will only be logged if any errors are present there. To change this, use 'showXcodeLog' desired capability
[XCUITest] Waiting up to 60000ms for WebDriverAgent to start
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[XCUITest] Log file for xcodebuild test: /Users/keyuan/Library/Developer/Xcode/DerivedData/WebDriverAgent-akxhdiizyykdxefsthlnfyomlaiz/Logs/Test/Test-WebDriverAgentRunner-2020.09.23_13-52-06-+0800.xcresult/Staging/2_Test/Diagnostics/WebDriverAgentRunner-256F6B6C-E4D2-4E3E-B008-0DC0E4BA1A32/WebDriverAgentRunner-7A849D89-0104-473C-AA3C-2F6E5597FFFA/Session-WebDriverAgentRunner-2020-09-23_135209-N744Uk.log
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8100}
[WD Proxy] Matched '/status' to command name 'getStatus'

氧化钙 [该话题已被删除] 中提及了此贴 01月22日 10:42
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册