Appium appium XCUITest 运行出现内部异常 Internal Server Error

思寒_seveniruby · October 09, 2016 · Last by 狼咩咩 replied at March 24, 2017 · 3432 hits

打算测试下ios10 然后就升级了xcode到8. 升级appium到 appium1.6.0-beta3

修改automationName=XCUITest. 运行的时候发现报错了. 提示

Unexpected token I in JSON at position 0

从appium的启动log中发现启动wda的命令是这个
我就单独启动wda

xcodebuild build test -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=4F05E384-FE32-43DE-8539-4DC3E2EBC117 -configuration Debug' in directory '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

然后模拟基本的发送webdriver的api

curl -X POST http://192.168.100.65:8100/session
Internal Server Error

竟然报错了
大家有遇到吗

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

webdriveragent对ios10 的支持目前貌似有点问题。WebDriverAgent的官网上还有这个issue

我把xcode升级到8, 把appium升级到1.6.0-beta1后进行自动化测试,APP刚被调起就闪退,模拟器也跟着闪退,终端显示的log如下:

[HTTP] --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"iPhone SE","automationName":"XCUITest","appium-version":"1.6.0-beta1","platformVersion":"10.0","platformName":"iOS","app":"/Users/wanqingyao/Desktop/campus.app"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"iPhone SE",...
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] deviceName: 'iPhone SE'
[Appium] automationName: 'XCUITest'
[Appium] appium-version: '1.6.0-beta1'
[Appium] platformVersion: '10.0'
[Appium] platformName: 'iOS'
[Appium] app: '/Users/wanqingyao/Desktop/campus.app'
[debug] [XCUITest] XCUITestDriver version: 2.0.25
[BaseDriver] The following capabilities were provided, but are not recognized by appium: appium-version.
[BaseDriver] Session created with session id: 868d7623-877a-4b77-a5dd-9011fb27257b
[debug] [XCUITest] Xcode version set to '8.0'
[debug] [XCUITest] iOS SDK Version set to '10.0'
[iOSSim] Constructing iOS simulator for Xcode version 8.0 with udid 'F7BF2FD0-6458-4CA1-8E25-FF17E971E20E'
[XCUITest] Determining device to run tests on: udid: 'F7BF2FD0-6458-4CA1-8E25-FF17E971E20E', real device: false
[BaseDriver] Using local app '/Users/wanqingyao/Desktop/campus.app'
[debug] [XCUITest] Checking whether app is actually present
[debug] [ios-app-utils] Getting bundle ID from app
[debug] [iOSLog] Starting iOS 10.0 simulator log capture
[debug] [iOSLog] System log path: /Users/wanqingyao/Library/Logs/CoreSimulator/F7BF2FD0-6458-4CA1-8E25-FF17E971E20E/system.log
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[XCUITest] Simulator with udid 'F7BF2FD0-6458-4CA1-8E25-FF17E971E20E' not booted. Booting up now
[debug] [iOSSim] Killing all iOS Simulators
[iOSSim] Starting simulator with command: open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID F7BF2FD0-6458-4CA1-8E25-FF17E971E20E
[iOSSim] Tailing simulator logs until we encounter the string "SMS Plugin initialized"
[iOSSim] We will time out after 60000ms
[debug] [iOSSim] Waiting an extra 10000ms for the simulator to really finish booting
[debug] [iOSSim] Done waiting extra time for simulator
[iOSSim] Simulator booted in 63512ms
[debug] [XCUITest] Installing app '/Users/wanqingyao/Desktop/campus.app' on device
[XCUITest] Using default agent: /usr/local/lib/node_modules/.appium_npminstall/node_modules/.2.0.25@appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
[XCUITest] Using default bootstrap: /usr/local/lib/node_modules/.appium_npminstall/node_modules/.2.0.25@appium-xcuitest-driver/WebDriverAgent
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: /usr/local/bin/carthage
[debug] [XCUITest] Beginning test with command 'xcodebuild build test -project /usr/local/lib/node_modules/.appium_npminstall/node_modules/.2.0.25@appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=F7BF2FD0-6458-4CA1-8E25-FF17E971E20E -configuration Debug' in directory '/usr/local/lib/node_modules/.appium_npminstall/node_modules/.2.0.25@appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Waiting for WebDriverAgent to start on device
[debug] [XCUITest] Log file for xcodebuild test: /Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Logs/Test/A16E3068-6D91-43D8-86CC-EA6794C3BFC1/Session-WebDriverAgentRunner-2016-10-09_194407-y1CzXI.log
[debug] [WebDriverAgent] Sim: Oct 9 19:44:13 wanqingyaodeMac CoreSimulatorBridge[2257]: Requesting installation of file:///Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/ with options: {
[debug] [WebDriverAgent] Sim: CFBundleIdentifier = "com.apple.test.WebDriverAgentRunner-Runner";
[debug] [WebDriverAgent] Sim: PackageType = Developer;
[debug] [WebDriverAgent] Sim: SimulatorRootPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk";
[debug] [WebDriverAgent] Sim: SimulatorUserPath = "/Users/wanqingyao/Library/Developer/CoreSimulator/Devices/F7BF2FD0-6458-4CA1-8E25-FF17E971E20E/data";
[debug] [WebDriverAgent] Sim: }
[debug] [WebDriverAgent] Sim: Oct 9 19:44:19 wanqingyaodeMac CoreSimulatorBridge[2257]: Requesting launch of com.apple.test.WebDriverAgentRunner-Runner with options: {
[debug] [WebDriverAgent] Sim: arguments = (
[debug] [WebDriverAgent] Sim: "-NSTreatUnknownArgumentsAsOpen",
[debug] [WebDriverAgent] Sim: NO,
[debug] [WebDriverAgent] Sim: "-ApplePersistenceIgnoreState",
[debug] [WebDriverAgent] Sim: YES
[debug] [WebDriverAgent] Sim: );
[debug] [WebDriverAgent] Sim: environment = {
[debug] [WebDriverAgent] Sim: "DTX_CONNECTION_SERVICES_PATH" = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/PrivateFrameworks/DTXConnectionServices.framework";
[debug] [WebDriverAgent] Sim: "DYLD_FRAMEWORK_PATH" = "/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator:/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks";
[debug] [WebDriverAgent] Sim: "DYLD_LIBRARY_PATH" = "/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator:/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks";
[debug] [WebDriverAgent] Sim: NSUnbufferedIO = YES;
[debug] [WebDriverAgent] Sim: "OS_ACTIVITY_DT_MODE" = YES;
[debug] [WebDriverAgent] Sim: "XCODE_DBG_XPC_EXCLUSIONS" = "com.apple.dt.xctestSymbolicator";
[debug] [WebDriverAgent] Sim: XCTestConfigurationFilePath = "/var/folders/tf/89068tvn199bhwpk5r3hg03h0000gn/T/com.apple.dt.XCTest/630FF0A9-E7F8-4D71-B2E2-0D775AF2E5B6/remote-container/tmp/WebDriverAgentRunner-630FF0A9-E7F8-4D71-B2E2-0D775AF2E5B6.xctestconfiguration";
[debug] [WebDriverAgent] Sim: "__XCODE_BUILT_PRODUCTS_DIR_PATHS" = "/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: "__XPC_DYLD_FRAMEWORK_PATH" = "/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: "__XPC_DYLD_LIBRARY_PATH" = "/Users/wanqingyao/Library/Developer/Xcode/DerivedData/WebDriverAgent-efaqvcgcmeyaledxsduiebeyiwfc/Build/Products/Debug-iphonesimulator";
[debug] [WebDriverAgent] Sim: };
[debug] [WebDriverAgent] Sim: stderr = "/dev/ttys001";
[debug] [WebDriverAgent] Sim: stdout = "/dev/ttys001";
[debug] [WebDriverAgent] Sim: "wait_for_debugger" = 0;
[debug] [WebDriverAgent] Sim: }
[debug] [WebDriverAgent] Sim: Oct 9 19:44:19 wanqingyaodeMac CoreSimulatorBridge[2257]: [Common] [FBSSystemService][0x2cdb] Sending request to open "com.apple.test.WebDriverAgentRunner-Runner"
[debug] [WebDriverAgent] Sim: Oct 9 19:44:19 wanqingyaodeMac CoreSimulatorBridge[2257]: [Common] [FBSSystemService][0x2cdb] Request successful: <FBSProcessHandle: 0x7f915bc2f560; XCTRunner:2591; valid: YES>
[debug] [WebDriverAgent] Sim: Oct 9 19:44:20 wanqingyaodeMac XCTRunner[2591]: assertion failed: 15G31 14A345: libxpc.dylib + 62597 [37A9DF49-35C1-3D93-B854-B35CACF0100F]: 0x7d
[debug] [WebDriverAgent] Sim: Oct 9 19:44:20 wanqingyaodeMac XCTRunner[2591]: Running tests...
[debug] [WebDriverAgent] Sim: Oct 9 19:44:28 --- last message repeated 1 time ---
[debug] [WebDriverAgent] Sim: Oct 9 19:44:28 wanqingyaodeMac XCTRunner[2591]: Continuing to run tests in the background with task ID 1
[debug] [WebDriverAgent] Sim: Oct 9 19:44:29 --- last message repeated 14 times ---
[debug] [WebDriverAgent] Sim: Oct 9 19:44:29 wanqingyaodeMac XCTRunner[2591]: Built at Oct 9 2016 19:44:10
[XCUITest] Detected that WebDriverAgent is running at url 'http://192.168.44.128:8100'
[debug] [WebDriverAgent] Sim: Oct 9 19:44:29 wanqingyaodeMac XCTRunner[2591]: ServerURLHere->http://192.168.44.128:8100<-ServerURLHere
[XCUITest] WebDriverAgent started at url 'http://192.168.44.128:8100'
[JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bu...
[JSONWP Proxy] Got response with status 200: {"value":{"sessionId":"B570...
[Appium] New XCUITestDriver session created successfully, session 868d7623-877a-4b77-a5dd-9011fb27257b added to master session list
[MJSONWP] Responding to client with driver.createSession() result: {"
webStorageEnabled":false,...
[HTTP] <-- POST /wd/hub/session 200 113848 ms - 444
[HTTP] --> POST /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b/element {"
using":"xpath","sessionId":"868d7623-877a-4b77-a5dd-9011fb27257b","value":"//UIAApplication[1]/UIAWindow[7]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]"}
[MJSONWP] Calling AppiumDriver.findElement() with args: ["xpath","//UIAApplication[...
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, accessibility id
[XCUITest] Rewrote incoming selector from '//UIAApplication[1]/UIAWindow[7]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]' to '//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[7]/XCUIElementTypeAlert[1]/XCUIElementTypeCollectionView[1]/XCUIElementTypeCollectionCell[2]' to match XCUI type. You should consider updating your tests to use the new selectors directly
[debug] [BaseDriver] Waiting up to 0 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/B5700BA5-8AE3-425B-B02F-D7EE6A498479/element] with body: {"
using":"xpath","value":"/...
[JSONWP Proxy] Got response with status 200: {"value":{"using":"xpath","...
[HTTP] <-- POST /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b/element 500 272 ms - 164
[HTTP] --> POST /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b/appium/app/close {"
sessionId":"868d7623-877a-4b77-a5dd-9011fb27257b"}
[MJSONWP] Calling AppiumDriver.closeApp() with args: ["
868d7623-877a-4b77-a5dd-9...
[debug] [XCUITest] Executing command 'closeApp'
[JSONWP Proxy] Proxying [DELETE /session/868d7623-877a-4b77-a5dd-9011fb27257b] to [DELETE http://localhost:8100/session/B5700BA5-8AE3-425B-B02F-D7EE6A498479] with no body
[JSONWP Proxy] Got response with status 200: "{\n \"value\" : {\n\n },...
[XCUITest] Shutting down WebDriverAgent
[XCUITest] Simulator log exited with code 'null'
[XCUITest] xcodebuild exited with code 'null' and signal 'SIGTERM'
[debug] [XCUITest] Running iOS simulator reset flow
[debug] [XCUITest] Shutting down simulator
[debug] [iOSSim] Killing all iOS Simulators
[debug] [XCUITest] Cleaning simulator state.
[debug] [iOSSim] Cleaning app data files for 'campus.app', 'com.whmx.campus'
[debug] [iOSSim] Building bundle path map
[debug] [iOSSim] Building bundle path map
[debug] [iOSSim] Deleting directory: '/Users/wanqingyao/Library/Developer/CoreSimulator/Devices/F7BF2FD0-6458-4CA1-8E25-FF17E971E20E/data/Containers/Data/Application/3923C5FA-171A-4388-B616-292707A043AC'
[debug] [iOSSim] Deleting directory: '/Users/wanqingyao/Library/Developer/CoreSimulator/Devices/F7BF2FD0-6458-4CA1-8E25-FF17E971E20E/data/Containers/Bundle/Application/7FC319A9-7801-42EF-8417-4227518FA609'
[debug] [iOSSim] Deleting file: '/Users/wanqingyao/Library/Developer/CoreSimulator/Devices/Library/Preferences/com.whmx.campus.plist'
[debug] [iOSSim] Killing any simulator daemons for F7BF2FD0-6458-4CA1-8E25-FF17E971E20E
[iOSSim] Cleaning simulator F7BF2FD0-6458-4CA1-8E25-FF17E971E20E
[debug] [XCUITest] Resetting simulator
[debug] [XCUITest] Shutting down simulator
[debug] [iOSSim] Killing all iOS Simulators
[debug] [iOSLog] Stopping iOS log capture
[iOS] Successfully closed the [/Users/wanqingyao/Desktop/campus.app] app.
[MJSONWP] Responding to client with driver.closeApp() result: null
[HTTP] <-- POST /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b/appium/app/close 200 14952 ms - 76
[HTTP] --> DELETE /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["
868d7623-877a-4b77-a5dd-9...
[debug] [XCUITest] Running iOS simulator reset flow
[Appium] Removing session 868d7623-877a-4b77-a5dd-9011fb27257b from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/868d7623-877a-4b77-a5dd-9011fb27257b 200 3 ms - 76

其中有两句log是这样的:

[BaseDriver] The following capabilities were provided, but are not recognized by appium: appium-version.
[XCUITest] Rewrote incoming selector from '//UIAApplication[1]/UIAWindow[7]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]' to '//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[7]/XCUIElementTypeAlert[1]/XCUIElementTypeCollectionView[1]/XCUIElementTypeCollectionCell[2]' to match XCUI type. You should consider updating your tests to use the new selectors directly

我这个闪退的原因是什么呢,莫非也是因为webdriveragent对ios10的支持有问题?还是说脚本中原来xpath定位的路径修要修改?向大家请教一下,求指导😀

其实WDA是工作的, 只是一开始appium发送了session的请求导致出错了. 执行其他的source命令, 还是可以正常工作的

想请教下:
xctest ui是需要建立在项目里的,然后用官网的方法是 xcodebuild test xxxx。用appium运行的时候,是如何把脚本独立出来就能运行的?中间过度大概如何实现的···。目前用swift写了脚本,但是一定要放到项目里。有什么方法可以独立在项目外么。
场景是:
monkey 脚本

#4楼 @ws328686288 看appium的log就行了. 他封装了对应的命令. 用xcodebuild可以独立运行的.

#5楼 @seveniruby 好,我试试。thx

请问楼主解决了吗?我的也一直闪退,log:
[debug] [XCUITest] Failed to create session. Retrying...
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Got response with status 200: {"value":"Application is not running, possibly crashed","sessionId":"9B082815-E67B-40B6-B2F4-A527091C6C07","status":10}
[debug] [XCUITest] Failed to create session. Retrying...

#7楼 @Trinity 用ios10即可 不支持低版本的模拟器

#8楼 @seveniruby 我用的ios10.2系统,唤起app就闪退,log一直提示Failed to create session,这是为啥呀

Trinity 回复

问题解决了吗?

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