Appium appium + iOS10.2 + Xcode8.2.1 + React Native 完成自动化测试

steven · March 03, 2017 · Last by 不贱不散 replied at August 26, 2019 · 7182 hits
本帖已被设为精华帖!

背景

  1. Appium 目前最新的版本是 1.6.3 ,appium 客户端 (appium server 的 GUI 图形化操作界面) 最新版本是 1.5.3, 但是 appium GUI 目前还只支持到iOS10以下基于UIAutomation框架的测试,而iOS10以后苹果已经更改为XCUITest

  2. 我们项目中想要做到对开发代码无侵染的方式来达到自动化测试的目的(这就需要通过 xpath 的方式去查找页面元素)

  3. 项目是使用 React Native 跨平台开发的应用

综合这三个背景,并且 iOS + React Native 结合的相关资料又比较少,就注定我要在自动化测试的道路上踩坑,写这篇这个也是想给后面玩的同学们一个肯定回答:appium + iOS10.2 + Xcode8.2.1 + React Native即使不在代码加 accessibilityLabel 或 TestID,就用 xpath 照样玩得转

开发环境

  • 系统:macOS Sierra(10.12.3)
  • 开发工具:Xcode 8.2.1(iOS10.2)+ Xcode7.3.1(iOS9.3)

前期准备

需要安装的辅助工具

  • homebrew
  • npm/cnpm
  • node

环境搭建

经过一个星期的折腾,最终搭建满足 UIAutomation 和 XCUITest 的测试环境:

  • iOS10 以下支持 UIAutomation

    appium GUI1.5.3 + Xcode7.3.1(iOS9.3) + appium-python-client

  • iOS10 以上支持 XCUITest

    appium1.6.3 + app-inspector + Xcode8.2.1(iOS10.2) + appium-python-client

1. 使用 npm 或 cnpm 安装 appium,appium-doctor

$ npm install -g appium
$ npm install -g appium-doctor

2. 下载 appium GUI

appium 和 appium GUI 只要安装其中一项就可以启动服务,但是如果要用到其中的 inspector 去检查元素的 xpath,所以还是安装了

下载地址. appium-desktop

安装最新的版本 1.5.3 就行,但是即使最新的,也只能支持 iOS10 以下系统的元素检查。

3. 使用 appium-doctor 检查 appium 环境

$ appium-doctor //appium-doctor --ios 只检测iOS环境
info AppiumDoctor Appium Doctor v.1.4.1
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ✔ Node version is 6.3.1
info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode_7.3.1.app/Contents/Developer
info AppiumDoctor ✔ Xcode Command Line Tools are installed.
info AppiumDoctor ✔ DevToolsSecurity is enabled.
info AppiumDoctor ✔ The Authorization DB is set up properly.
info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage
info AppiumDoctor ✔ HOME is set to: /Users/iSteven
info AppiumDoctor ✔ ANDROID_HOME is set to: /Users/iSteven/Library/Android/sdk
info AppiumDoctor ✔ JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
info AppiumDoctor ✔ adb exists at: /Users/iSteven/Library/Android/sdk/platform-tools/adb
info AppiumDoctor ✔ android exists at: /Users/iSteven/Library/Android/sdk/tools/android
info AppiumDoctor ✔ emulator exists at: /Users/iSteven/Library/Android/sdk/tools/emulator
info AppiumDoctor ✔ Bin directory of $JAVA_HOME is set
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor

环境常见问题解决:

  • ✖ Xcode Command Line Tools are NOT installed!

    $ xcode-select --install #按照提示安装即可

  • ✖ Carthage was NOT found!

    $ brew install carthage #carthage:类似cocoapods管理第三方代码,自动将工程编译为动态库,所以仅支持iOS8以上

  • WARN AppiumDoctor ✖ ANDROID_HOME is NOT set!

  • 在.bash_profile/.zshrc 文件中设置 JAVA 和 Android 环境变量

    #android sdk
    export ANDROID_HOME=~/Library/Android/sdk
    export PATH="$HOME/.yarn/bin:$PATH"
    #java_home
    export JAVA_HOME=$(/usr/libexec/java_home)
    export PATH=$JAVA_HOME/bin:$PATH
    export CLASS_PATH=$JAVA_HOME/lib

4. 安装 appium client 端

appium client 有 ruby,python,java 三个版本,可自行选择自己喜欢的安装即可

python 版
  • pip 安装

pip install Appium-Python-Client
如果安装过程出现 could not create ‘/Library/Python/2.7/site-packages/appium’: Permission denied 错误,

使用 pip install Appium-Python-Client –user 命令可以安装成功

  • 源码安装 在 Pipy 上下载源码安装

tar -xvf Appium-Python-Client-X.X.tar.gz
cd Appium-Python-Client-X.X
python setup.py install

  • github 安装

git clone git@github.com:appium/python-client.git
cd python-client
python setup.py install

ruby 版(一定要在线安装)

ruby 的 appium client 叫做 appium lib,为什么是这样就不解释了,总之是历史原因。

首先 update rubygem 和 bundler(说老实话,真的不需要,但官方文档上这么写)

gem update --system
gem update bundler

然后使用 gem 安装

gem uninstall -aIx appium_lib \\(这个也不是必须的)
gem install --no-rdoc --no-ri appium_lib

java 版(在线安装)

java 的话用 maven 安装就可以了

<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>1.3.0</version>
</dependency>

也可以自己下载 jar 包,请自行选择最新版本。

5. 其他相关安装

brew install libimobiledevice --HEAD
brew install ideviceinstaller
npm install -g ios-deploy
sudo gem install xcpretty

6. 安装 app-inspector

npm install app-inspector -g

到这里所有相关的环境就已经安装好了,下面就可以开始撸起袖子干了,也是大家的踩坑时间了

如果以上安装还有问题,可以参考:

在 MAC 上搭建 appium1.6.3 过程
appium1-macOS10.12 下如何丝滑的使用 appium?

运行 Demo

  1. 下载 demo
  2. 启动 appium 服务

    appium

  3. cd 到sample-code-master/sample-code/examples/python目录下,运行下面命令就可以成功运行示例了

    python ios_simple.py

    成功运行截图:

    Server 端成功运行:

    Client 端成功运行:

    要成功运行,得满足以下条件:

* 有安装 python
* 保证/apps/TestApp/build/release-iphonesimulator/TestApp.app 路径下存在 TestApp.app 这个文件
* 保证 ios_simple.py 示例中的 platVersion 填的是你 Xcode 版本有的 iOS 系统版本

遇到错误:

[XCUITest] Error: simctl error running 'install': An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.

执行跑 demo 的时候,app 安装不上, 将 app 文件直接移到同脚本同级目录,修改app = os.path.abspath('../../apps/TestApp/build/release-iphonesimulator/TestApp-iphonesimulator.app')
app = os.path.abspath('TestApp-iphonesimulator.app')即可。

到这里不出问题的话,恭喜你已经可以成功使用 Appium 自动化测试框架了

遇到的问题

这个过程中磕磕绊绊碰到了不少问题,现在只能列出稍微还记得的一些问题吧。

1. 通过 appium inspector Xpath 获取到的 React Native 页面封装的 TextInput 不能使用 sendkeys 或 set_Value 输入。

下图便是 appium inspector+Xcode7.3.1+iOS9.3 上 react native 页面元素,后面和 android 端同事比对下 xpath 路径,发现 iOS 这边路径明显比安卓短很多,后面通过 app-inspector 获取到也是要长很多 (获取到的是基于 XCUITest 的,元素都是以 XCUIElementType 标识),也就是说只有 appium 基于 UIAutomation 的版本 RN 的 ‘textfield’ 不支持直接使用 send_keys 或 set_value 来输入,应该 appium 1.5.3 中 inspector 对 rn 的适配还没那么好导致的。

解决方法:app-inspector 检查元素得到 xpath 即可正常输入。(尝试过 WebDriveAgent 获取 xpath,rn 页面整个是个 label 文字显示;也尝试过查找键盘上对应键再 click,速度太慢不能接受)

app-inspector 使用方法:

app-inspector -u <设备/模拟器UDID> //加 --verbose可查看详情

2. app-inspector 模拟器运行报错

server.js:16:12 [master] pid:32216 server start with config:
{ port: 5678,
verbose: true,
udid: 'DC8E88DF-EDA7-487A-9D34-77AA58B3ADB5',
ip: '10.180.185.87',
host: 'iStevendeMacBook-Pro.local',
loaded_time: '2017-02-27 16:42:19' }
app-inspector.js:42:10 [master] pid:32216 server start at: http://10.180.185.87:5678
xctest-client.js:56:14 [master] pid:32216 project path: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/xctest-client/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
xctest-client start with port: 8900
xctest-client.js:233:14 [master] pid:32216 xcode version: 7.3.1
WebDriverAgent version: 1.0.41
xctest-client.js:99:16 [master] pid:32216 tail: /Users/iSteven/Library/Logs/CoreSimulator/DC8E88DF-EDA7-487A-9D34-77AA58B3ADB5/system.log: No such file or directory
xctest-client.js:107:16 [master] pid:32216 simulator log process exit with code: 1, signal: null
xctest-client.js:255:14 [master] pid:32216 Fail to start xctest: undefined
xctest-client.js:267:14 [master] pid:32216 killing deviceLogProc pid: 32220
xctest-client.js:272:14 [master] pid:32216 killing runnerProc pid: 32221
app-inspector:66:44 [master] pid:32216 undefined
xctest-client.js:181:14 [master] pid:32216 xctest client exit with code: null, signal: SIGKILL

这个问题还去提了 issue,但是后面自己卸载再重装就好了,也不知道是什么东西没装好还是咋的,希望有清楚的可以回答下

遇到这样问题可按这里配置下环境试试macaca 环境配置

成功运行之后就是可以看到下图,并且会自动打开浏览器,load 模拟器或者真机。

3. app-inspector 真机运行报错

>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:11850 2017-03-03 16:09:44.301 xcodebuild[11856:248062] Error Domain=com.apple.dtdevicekit Code=-402652994 "App installation failed" UserInfo={NSLocalizedFailureReason=This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed., com.apple.dtdevicekit.stacktrace=(
0 DTDeviceKitBase 0x000000011145537b DTDKCreateNSError + 113
1 DTDeviceKitBase 0x0000000111455ab9 DTDK_AMDErrorToNSError + 791
2 DTDeviceKitBase 0x00000001114959df __90-[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 158
3 DVTFoundation 0x0000000108686989 DVTInvokeWithStrongOwnership + 75
4 DTDeviceKitBase 0x0000000111495725 -[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1181
5 IDEiOSSupportCore 0x000000011138be1f __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.336 + 4597
6 DVTFoundation 0x00000001087aacb7 __DVTDispatchAsync_block_invoke + 827
7 libdispatch.dylib 0x00007fffacd96ef7 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x00007fffacd8e0b8 _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fffacda4ae5 _dispatch_queue_serial_drain + 896
10 libdispatch.dylib 0x00007fffacd96cd9 _dispatch_queue_invoke + 1046
11 libdispatch.dylib 0x00007fffacd8fe70 _dispatch_root_queue_drain + 476
12 libdispatch.dylib 0x00007fffacd8fc47 _dispatch_worker_thread3 + 99
13 libsystem_pthread.dylib 0x00007fffacfdb712 _pthread_wqthread + 1299
14 libsystem_pthread.dylib 0x00007fffacfdb1ed start_wqthread + 13
), NSLocalizedRecoverySuggestion=This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed., NSLocalizedDescription=App installation failed}
>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:11850 2017-03-03 16:09:44.301 xcodebuild[11856:248062] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:11850
Testing failed:
Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:11850 ** TEST FAILED **
>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:267:14 [master] pid:11850 killing deviceLogProc pid: 11853
>> xctest-client.js:272:14 [master] pid:11850 killing runnerProc pid: 11856
>> xctest-client.js:278:14 [master] pid:11850 killing iproxyProc pid: 11855
>> xctest-client.js:181:14 [master] pid:11850 xctest client exit with code: 65, signal: null
>> xctest-client.js:209:14 [master] pid:11850 iproxy exit with code: null, signal: SIGKILL
>> xctest-client.js:145:16 [master] pid:11850 deviceconsole exit with code: null, signal: SIGKILL
>> xctest-client.js:255:14 [master] pid:11850 Fail to start xctest: undefined
>> app-inspector:66:44 [master] pid:11850 undefined

捕捉关键信息

>> xctest-client.js:171:14 [master] pid:11850 please check project: /Users/iSteven/.nvm/versions/node/v6.3.1/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:11850
2017-03-03 16:09:44.301 xcodebuild[11856:248062] Error Domain=com.apple.dtdevicekit Code=-402652994 "App installation failed" UserInfo={NSLocalizedFailureReason=This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed.,

从上面看就是 bundle-id 错误,进到 WebDriverAgent 工程目录下修改工程 bundle-id 重新运行即可

4. 团队里有人因为先安装 Appium 后再安装 Xcode 获取不到 Xcode 版本问题,具体错误信息如下:

WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not determine Xcode version: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.

解决办法: 卸载 Appium,重新安装

5. WebDriverAgent 相关依赖安装出错

[Xcode] 2017-04-05 16:09:12.331 xcodebuild[91135:3418654] Error Domain=IDEFoundationErrorDomain Code=1 "Cannot launch simulated executable: no file found at /Users/Chetwyn/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app" UserInfo={NSLocalizedDescription=Cannot launch simulated executable: no file found at /Users/Chetwyn/Library/Developer/Xcode/DerivedData/WebDriverAgent-cvqckynzuuktkogfpkkkgyompmoj/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app}
[Xcode] 
[Xcode] 2017-04-05 16:09:12.331 xcodebuild[91135:3418654] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

解决办法: 卸载 appium-xcuitest-driver,重新安装,再执行./Scripts/bootstrap.sh -d

npm uninstall appium-xcuitest-driver
nom install appium-xcuitest-driver
./Scripts/bootstrap.sh -d

6. 最近 Xcode 升级到 8.3, WebDriverAgent 工程跑不起来,报错误:"XCUISiriService is partial: introduced in iOS 10.3 XCUIDevice.h"

解决办法: 找到 WebDriverAgent/Configurations/ProjectSettings.xcconfig 文件,在原来
WARNING_CFLAGS = $(inherited) -Weverything -Wno-objc-missing-property-synthesis -Wno-unused-macros -Wno-disabled-macro-expansion -Wno-gnu-statement-expression -Wno-language-extension-token -Wno-overriding-method-mismatch -Wno-missing-variable-declarations -Rno-module-build -Wno-auto-import -Wno-objc-interface-ivars -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-unused-parameter -Wno-gnu-conditional-omitted-operand -Wno-explicit-ownership-type -Wno-date-time -Wno-cast-align -Wno-cstring-format-directive -Wno-double-promotion -Wno-partial-availability

后面加上-Wno-partial-availability即可

WebdirverAgent 上相关 issue: Silence unguarded availability warning from Xcode 8.3 #525

最后找到其解决的commit

参考资料

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 46 条回复 时间 点赞

没有写完?没看到 RN 那一块。

2Floor has deleted

@iSteven 看到你用的是模拟器,请问真机可以吗

steven #4 · March 04, 2017 Author
Joyce306 回复

真机也是可以的

steven #5 · March 04, 2017 Author
恒温 回复

我就是基于 RN 的 app 上做的测试,上面截图就是 rn 页面,只是说在 rn 页面上通过 appium inspector 获得的 xpath 去获取的页面元素时 textInput 不能通过 sendKeys,set_value 输入,其它暂时没发现和原生 app 有区别的地方,用阿里的 app-inspector 得到的 xpath 就可以正常输入

页面有 native 链接的话就会是一整块的,如果页面是纯 RN 或链接到的页面页面 RN 页面,就可以正常抓取

匿名 #7 · March 06, 2017

怎么经常有时候同一套代码,刚开始初始化 driver 的时候,有时间会非常慢,有知道原因的吗?

匿名 #8 · March 06, 2017

我看了下应该是卡在 appium 这里,它的 server 端一直没有打印日志了,但是又没有死掉,不知道为什么

steven #9 · March 06, 2017 Author
lmlucky 回复

没明白什么意思,获取不到 xpath 吗?

steven 回复

对,就是获取不到 xpath,纯 RN 页面就可以抓取到,不知题主有没有遇到过这种情况

11Floor has deleted
steven #12 · March 09, 2017 Author
lmlucky 回复

我们应用也有 rn 页面跳转 native 页面的入口,暂时还没遇到你说的问题

steven #13 · March 09, 2017 Author

初始化 driver 需要一定时间,如果一次性跑多个用例可以把 driver 初始化写成单利就不用跑下个 case 的时候再重新出始化

steven #14 · March 16, 2017 Author
lmlucky 回复

我现在也遇到这个问题,RN 页面弹出的 Native 控件获取不到上面的具体元素,请问你有好的解决办法了吗? 我现在只能使用 tap 来点击对应位置。

Xcode Command Line Tools are NOT installed!
xcode-select --install

安装又提示不能安装软件
,这是什么原因

app-inspector 有 xpath 么,我安装的咋是没 xpath 的

steven #17 · April 06, 2017 Author
回复

app-inspector -u 就可以在浏览器看到 xpath 了

steven #18 · April 06, 2017 Author
recall1951 回复

没遇到过,有具体错误的截图吗?

steven 回复

报错,搭建没成功的

autotest-ios:WebDriverAgent admin$ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=2a7cd84d5d266bdb2558972eb894aadbd8393481 test
2017-04-11 11:12:45.541 xcodebuild[5862:2495176] IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
/Users/admin/Library/Developer/Xcode/DerivedData/WebDriverAgent-cawmfybafmqbwbbksnlvaaamrjla/Logs/Test/9A4CA41F-2763-4112-AE20-02EA341C4C9A/Session-WebDriverAgentRunner-2017-04-11_111245-tEciTq.log
2017-04-11 11:12:45.541 xcodebuild[5862:2495089] [MT] IDETestOperationsObserverDebug: (43A30FB3-98FA-42FD-8C6F-9C36A2018879) Beginning test session WebDriverAgentRunner-43A30FB3-98FA-42FD-8C6F-9C36A2018879 at 2017-04-11 11:12:45.541 with Xcode 8E162 on target {
deviceSerialNumber: C8QLD5B1FFHR
identifier: 2a7cd84d5d266bdb2558972eb894aadbd8393481
deviceClass: iPhone
deviceName: iPhone5c 10.1
deviceIdentifier: 2a7cd84d5d266bdb2558972eb894aadbd8393481
productVersion: 10.2.1
buildVersion: 14D27
deviceSoftwareVersion: 10.2.1 (14D27)
deviceArchitecture: armv7s
deviceTotalCapacity: 13087301632
deviceAvailableCapacity: 7095791616
deviceIsTransient: NO
ignored: NO
deviceIsBusy: NO
deviceIsActivated: YES
deviceActivationState: Activated
isPasscodeLocked: NO
deviceType:
supportedDeviceFamilies: (
1
)
applications: (null)
provisioningProfiles: (null)
activityProgress: -2
activityTitle:

hasInternalSupport: NO
isSupportedOS: YES
developerDiskMountError: (null)
(null)
bootArgs:
} (10.2.1 (14D27))
=== BUILD TARGET WebDriverAgentLib OF PROJECT WebDriverAgent WITH CONFIGURATION Debug ===

Check dependencies

=== BUILD TARGET IntegrationApp OF PROJECT WebDriverAgent WITH CONFIGURATION Debug ===

Check dependencies

Validate /Users/admin/Library/Developer/Xcode/DerivedData/WebDriverAgent-cawmfybafmqbwbbksnlvaaamrjla/Build/Products/Debug-iphoneos/IntegrationApp.app
cd "/usr/local/lib/node_modules/appium/node_modules/._appium-xcuitest-driver@2.27.2@appium-xcuitest-driver/WebDriverAgent"
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/appium/nodejs/bin:/Users/admin/.rvm/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/java/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/java/jre/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/bin:/Users/admin/Desktop/WXJ_IOS/android-sdk-macosx/tools:/Users/admin/Desktop/WXJ_IOS/android-sdk-macosx/platform-tools:/Users/admin/Desktop/WXJ_IOS/android-sdk-macosx/build-tools/25.0.2:"
export PRODUCT_TYPE=com.apple.product-type.application
builtin-validationUtility /Users/admin/Library/Developer/Xcode/DerivedData/WebDriverAgent-cawmfybafmqbwbbksnlvaaamrjla/Build/Products/Debug-iphoneos/IntegrationApp.app

=== BUILD TARGET WebDriverAgentRunner OF PROJECT WebDriverAgent WITH CONFIGURATION Debug ===

Check dependencies

MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/b2/xryd_gbj04b2g5_r1yxsv7cm0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/045d1d24e6381edd91309c864f77f536/2a7cd84d5d266bdb2558972eb894aadbd8393481/WebDriverAgentRunner-Runner.app
state->new_bundle: /Users/admin/Library/Developer/Xcode/DerivedData/WebDriverAgent-cawmfybafmqbwbbksnlvaaamrjla/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app
state->dst_bundle: /var/folders/b2/xryd_gbj04b2g5_r1yxsv7cm0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.oDauLw/WebDriverAgentRunner-Runner.app_sparse.ipa/Payload//WebDriverAgentRunner-Runner.app, binaryDiff flag: FALSE
dst_ipa: /var/folders/b2/xryd_gbj04b2g5_r1yxsv7cm0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.oDauLw/WebDriverAgentRunner-Runner.app_sparse.ipa
__MDMDirectoryDiff_block_invoke.37:1473 calling writeDictToFile with: /var/folders/b2/xryd_gbj04b2g5_r1yxsv7cm0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.oDauLw/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/b2/xryd_gbj04b2g5_r1yxsv7cm0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.oDauLw/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
Test Suite 'All tests' started at 2017-04-11 11:12:56.159
Test Suite 'WebDriverAgentRunner.xctest' started at 2017-04-11 11:12:56.164
Test Suite 'UITestingUITests' started at 2017-04-11 11:12:56.166
Test Case '-[UITestingUITests testRunner]' started.
t = 0.00s Start Test at 2017-04-11 11:12:56.170
t = 0.01s Set Up
Z
[3]+ Stopped xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=2a7cd84d5d266bdb2558972eb894aadbd8393481 test

一直卡在 t = 0.01s Set Up

steven #21 · April 11, 2017 Author
Jake 回复

方便把设置的 driver 的 capabilities 贴出来吗?
Xcode 8E162 on target {
deviceSerialNumber: C8QLD5B1FFHR
identifier: 2a7cd84d5d266bdb2558972eb894aadbd8393481
deviceClass: iPhone
deviceName: iPhone5c 10.1
deviceIdentifier: 2a7cd84d5d266bdb2558972eb894aadbd8393481
productVersion: 10.2.1
buildVersion: 14D27
deviceSoftwareVersion: 10.2.1 (14D27)
deviceArchitecture: armv7s
deviceTotalCapacity: 13087301632
deviceAvailableCapacity: 7095791616
deviceIsTransient: NO
ignored: NO
deviceIsBusy: NO
deviceIsActivated: YES
deviceActivationState: Activated
isPasscodeLocked: NO
deviceType: <0x7fef3460b290 xcode.devicetype.iphone>
supportedDeviceFamilies: (
1
)
不知道这段打印的啥

跑 appium python 脚本报的错,怎么破
A new session could not be created. Details: Appium's IosDriver does not support xcode version 8.3.1. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.

steven #23 · April 28, 2017 Author
纪小莉 回复

提示很清楚,iOS10 以上需要使用 XCUITest,caps 里 autonmationName 改下就可以

@iSteven 哥,最近 Xcode 升级到 8.3, WebDriverAgent 工程跑不起来,报错误:"XCUISiriService is partial: introduced in iOS 10.3 XCUIDevice.h" 这个问题前一阵当时我加好了 运行没问题,今天我运行 appium 直接又给我蹦了,,,

steven #25 · May 10, 2017 Author
center_on 回复

仔细看日志应该可以看出什么问题的,提问也得把日志贴出来啊,就说崩了大家都不知道的

@iSteven 我安装 app-inspector 的时候出现这个问题 :
tenddeMacBook-Pro:~ tend$ npm install app-inspector -g
npm WARN deprecated win-spawn@2.0.0: use cross-spawn or cross-spawn-async instead.
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated node-uuid@1.4.7: Use uuid module instead
/usr/local/bin/inspector -> /usr/local/lib/node_modules/app-inspector/bin/app-inspector
/usr/local/bin/app-inspector -> /usr/local/lib/node_modules/app-inspector/bin/app-inspector

fsevents@1.1.1 install /usr/local/lib/node_modules/app-inspector/node_modules/fsevents
node install

[fsevents] Success: "/usr/local/lib/node_modules/app-inspector/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

xctestwd@1.0.15 install /usr/local/lib/node_modules/app-inspector/node_modules/xctestwd
node ./scripts/install.js

Successfully updated Bundle Id, but no Team Id was provided. Please update your team id manually in /usr/local/lib/node_modules/app-inspector/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj/project.pbxproj, or reinstall the module with DEVELOPMENT_TEAM_ID in environment variable.

uiautomatorwd@1.0.27 install /usr/local/lib/node_modules/app-inspector/node_modules/uiautomatorwd
node ./scripts/build.js

(node:1116) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Command failed: which gradle

思寒_seveniruby 将本帖设为了精华贴 17 May 00:35

迟到的加精

纪小莉 回复

请问你解决了吗

steven 回复

你好 我设置了
app = os.path.abspath('../../apps/TestApp/build/release-iphonesimulator/TestApp.app')
self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'app': app,
'platformName': 'iOS',
'platformVersion': '9.6',
'deviceName': 'iPhone 6s',
'autonmationName':'XCUITest',
})

但是执行时
[iOS] SessionNotCreatedError: A new session could not be created. Details: Appium's IosDriver does not support xcode version 8.2. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.

appium 版本 1.6.4 xcode 版本 8.2

steven #31 · May 18, 2017 Author
957 回复

换 iOS10 以上的系统

app-inspector 运行的时候会自动关掉当前模拟器重新打开,这样的话 appium 打开模拟器的情况下会关掉,有什么办法能够同时存在,最理想的情况是,跑 case 的时候再另起一个模拟器

957 回复

在脚本里加入 XCUITest,就运行成功了

被标题骗进来了,结果没看到我想看的东西,失望

steven 回复

也还没有,不过坐标值是怎么得到的呢

请问可以解释下 5、6 安装的内容嘛?另外保证/apps/TestApp/build/release-iphonesimulator/TestApp.app 路径下存在 TestApp.app 这个文件 这个文件哪里来的?

WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not determine Xcode version: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.
你好 关于说的这个问题,重装也解决不了,xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance 重装后 出现这个错误,但是却是安装了

'deviceName': 'iPhone 6'请问
这个从哪里可以定义?

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Applications/PyCharm.app/Contents/helpers/pycharm/_jb_unittest_runner.py --path /Users/shixin/zuobiao/zuobiaoCase/LoginModel.py
Testing started at 上午 10:29 ...
Launching unittests with arguments python -m unittest /Users/shixin/zuobiao/zuobiaoCase/LoginModel.py in /Users/shixin/zuobiao/zuobiaoCase

Ran 0 tests in 0.042s

FAILED (errors=1)

Failure
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/unittest/suite.py", line 163, in handleClassSetUp
setUpClass()
File "/Users/shixin/zuobiao/zuobiaoCase/LoginModel.py", line 12, in setUpClass
cls.driver=GetAppiumDriver().driver
File "/Users/shixin/zuobiao/Utills/Common.py", line 7, in _singleton
instances[cls] = cls(args,*kw)
File "/Users/shixin/zuobiao/Utills/GetAppiumDriver.py", line 16, in __init
_
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub,desired_caps")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/webdriver.py", line 36, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 98, in init
self.start_session(desired_capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]} and you sent ["desiredCapabilities","capabilities"]

Stdout:

Process finished with exit code 1
appium 1.5.2 Mac10.12.4 jdk1.7
appium-doctor
代码在 win10 上跑的同,在 mac'上总是提示 selenium.common.exceptions.WebDriverException: Message: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]} and you sent ["desiredCapabilities","capabilities"]
困扰几天了,自己没找到问题的原因

41Floor has deleted
steven #42 · May 27, 2017 Author
Tester Xxinxin 回复

你试着用终端直接执行 python 文件,不通过 Pycharm 来执行脚步看可以跑不?如果 win10 可以通,脚本应该没问题,估计是环境问题

steven 回复

不知道那出了问题,自己也困扰几天了,没有办法解决

center_on 回复

解决了吗

app-inspector 安装后,Xcode 编译有报错,

这个问题还有遇到的?如何解决的?

@957 你的问题解决了吗,急需建议

@iSteven Mac10.12.5+Xcode8.3.3+appium1.6.5+ios10.3.2 真机运行报错 error: Sdk '10.3.2' was not in list of simctl sdks
运行脚本 可以在模拟器上跑, 用真机跑就报错
请指教谢谢

steven #48 · November 07, 2017 Author

真机的系统不是 10.3.2 吧,到 driver 里面改成真机的系统

###ios 测试中遇到无法定位的问题
appium ios react native 部分组件和自定义的 react native 组件无法定位,识别的不到里面具体元素,android 是可以的,rn 对 ios 支持不好吗,点击坐标确实可以,但是不同手机的分辨率的是不同的,请问还有别的的解决方案吗,最好是修改组件代码来实现,也不影响原来的组件使用最好了

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up