Appium in Mac for iOSのトラブルシュート


はじめに

こちらの記事を参考に進めたが、いろいろ嵌ったのでメモ。

環境

環境 バージョン
macOS 10.13.6
Xcode 9.4.1
Appium 1.9.0
iOS 11.4

UDIDの設定

iTunesのシリアル番号を使うという情報があったけど、自分の環境ではだめだった。

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unknown device or simulator UDID: '(シリアル番号)'

解決方法

Xcodeを起動して、Window > Devices and Simulators > Identifierの値を設定する。

test runに失敗

~/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent $ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=$udid' test
(省略)
Testing failed:
    Signing for "WebDriverAgentRunner" requires a development team. Select a development team in the project editor.
    Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 11.4'
** TEST FAILED **

The following build commands failed:
    Check dependencies
(1 failure)

解決方法

1)XcodeからWebDriverAgent.xcodeprjを開く
2)TargetsからWebDriverAgentRunnerを選択
3)Generalタブ > SigningのAutomatically manage signingにチェックを入れて、Teamは開発用のAppleIDを選択
4)Build Settingsタブ > Signing > Code Signing Identityは全てiOS Developerとなるように設定
5)Provisioning ProfileはAutomaticのまま
6)macOSを再起動(これめっちゃ重要)

Appium接続エラー

[Xcode] 2018-09-18 17:52:12.476 xcodebuild[2548:64487] 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, NSUnderlyingError=0x7f8948a03d40 {Error Domain=NSCocoaErrorDomain Code=260 "The file “WebDriverAgentRunner-Runner.app” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/debug/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app, NSUnderlyingError=0x7f89489303f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}
[Xcode]
[Xcode]
[Xcode] Testing failed:
[Xcode]
[Xcode]     Signing for "WebDriverAgentRunner" requires a development team. Select a development team in the project editor.
[Xcode]     Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 11.4'
[Xcode]     Early unexpected exit, operation never finished bootstrapping - no restart will be attempted
[Xcode] ** TEST EXECUTE FAILED **
[Xcode]
[Xcode]
[XCUITest] xcodebuild exited with code '65' and signal 'null'

解決方法

Appiumのdesired capabilityにagentPathbootstrapPathを追加する

desired_capabilities={
    'app': 'com.apple.mobileslideshow',
    'udid': '$udid',
    'platformName': 'iOS',
    'platformVersion': '11.4',
    'deviceName': 'iPhone 6',
    'agentPath': '/Users/debug/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj',
    'bootstrapPath': '/Users/debug/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
})