Appium1.6啟動iOS真機


 
前提:已經安裝了Appium1.6版本,我這里用的是GUI版本
 
環境要求:
真機iOS9.3及以上
macOS 10.11或10.12
Xcode7及以上
 

 安裝步驟如下

第一步:iOS真機啟動需要安裝libimobiledevice和ios-deploy工具
1.安裝libimobiledevice
【brew install libimobiledevice —HEAD】
 
2.安裝ios-deploy
【npm install -g ios-deploy】
 
 
第二步:安裝WebDriverAgent(WDA)
如果是模擬器測試,不需要安裝WDA,如果用真機一定要安裝WDA
 
 
第三步:配置啟動Desired Capabilities
注意項:
1.app或bundid使用一個即可
app:使用安裝包的絕對路徑(app或ipa的絕對路徑),
bundId:如果已安裝app可以使用bundlId免去安裝(com.wuba.zhuanzhuan等)
2.automationName使用XCUITest
3.新增xcodeOrgId,為打包時選擇的Development Team
4.新增xcodeSigningId,為打包時證書的名字
(證書名字和Team名稱,可以在打包選擇簽名和Team的地方點擊展開證書列表,選擇other時輸入框內的即為當前選擇的team或證書名)
5.udid:標識手機唯一標識。如果只插了一個手機可以用auto,會自動匹配到唯一的設備
 
{
  "platformName": "ios",
  "platformVersion": "9.3",
  "bundleId": "com.wuba.zhuanzhuan",
  "app": "/Users/a58/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/zhuanzhuan.app",
  "deviceName": "ZhuanZhuan",
  "automationName": "XCUITest",
  "udid": "c957fb5ec67c9d4568fdb206a4cb8f65b823896f",
  "xcodeOrgId": "xxx",
  "xcodeSigningId": “xxx"
}
 
然后Start Session能夠打開Inspector頁面即表示配置成功(GUI Appium界面的操作詳見另一篇隨筆:http://www.cnblogs.com/meitian/p/7360055.html)
 
官方給出的一些日志文件地址,不用時可以進行刪除
$HOME/Library/Logs/CoreSimulator/*
$HOME/Library/Developer/Xcode/DerivedData/*

Start Session時遇到的問題如下:

問題1:
An unknown server-side error occurred while processing the command. Original error: Could not create simulator with name 'appiumTest-55a8ede2-1b12-41ac-a37a-41d992a58bd0', device type id 'c957fb5ec67c9d4568fdb206a4cb8f65b823896f' and runtime id '9.3'. Reason: 'simctl error running 'create': Invalid device type: c957fb5ec67c9d4568fdb206a4cb8f65b823896f'
 
解決方法:
Appium1.6也必須設置udid,在啟動的Desired Capabilities增加udid
 
問題2:
Error
An unknown server-side error occurred while processing the command. Original error: Could not install app: 'Command 'ios-deploy --id c957fb5ec67c9d4568fdb206a4cb8f65b823896f --uninstall --bundle /Users/a58/Library/Developer/Xcode/DerivedData/Build/Products/Release-iphoneos/zhuanzhuan.app' exited with code 253'
 
 
解決方法:
將啟動Desired Capabilities中的app路徑換為Debug包的地址,不要使用Release的地址
 
問題3:使用模擬器,appium 啟動模擬器的session
An unknown server-side error occurred while processing the command. Original error: Command 'open -Fn '/Applications/Xcode 2.app/Contents/Developer/Applications/Simulator.app' --args -CurrentDeviceUDID 2D0F53CD-ECE6-4BBC-8062-3DD0A76111FE' exited with code 1
 
解決方法:
重新啟動appium server,然后再啟動start new session
 
原因:
我電腦上有Xcode8和Xcode7兩個版本,曾今切換到Xcode7過,然后后來又切換回Xcode8了,然后把Xcode7刪除了。
但是Appium這里沒更新地址,啟動的仍然是舊地址Xcode2.app。所以重啟一下就生效了
 
問題4:start new session時安裝app失敗(code=22)
[MJSONWP] Encountered internal error running command: Error: simctl error running 'install': An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22): Failed to install the requested application
 
解決方法:
Desired Capabilities 的app傳遞Debug包地址,例如:~/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos
 
原因:
Appium不支持release包,只支持debug包
 
問題5:啟動時xcodebuild失敗,code=65
An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
 
解決方法:編譯安裝WebDriverAgent
具體操作步驟詳見第二步
 
 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM