Appium 需要 5 分钟以上才能获得响应,同时自动化 iOS 应用程序



我观察到,当我第一次运行我的脚本时,我的脚本将运行得非常快,没有任何延迟响应。但是,如果我运行相同的脚本而没有任何更改或关闭模拟器或任何类型的重置,则以下 POST 请求需要 5 分钟以上才能获得响应。

来自Appium的请求:

[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bundleId":"XXX.XXXX.ios","arguments":[],"environment":{},"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}}

响应:

[debug] [JSONWP Proxy] Got response with status 200: {"value":{"sessionId":"91784C9C-3B63-40D3-9335-9C80548E7E68","capabilities":{"device":"iphone","browserName":null,"sdkVersion":"11.4","CFBundleIdentifier":null}},"sessionId":"91784C9C-3B63-40D3-9335-9C80548E7E68","status":0}

以下是我配置的版本

  • Xcode 版本:Xcode 9.4.1,内部版本 9F2000
  • Appium: v1.8.1 也 尝试使用 v1.9.1
  • 节点:5.6.0
  • Javac: javac 1.8.0_171
  • 裝置: 模擬器 (iPhone 7(
  • Appium Java-client: 6.1.0

完整的应用日志:

[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"app":"/Users/user.name/Desktop/XXXXX.app","noReset":false,"unhandledPromptBehavior":true,"deviceName":"iPhone 7","version":"","platform":"MAC","newCommandTimeout":1500,"platformVersion":"11.4","automationName":"XCUITest","browserName":"iPhone","platformName":"IOS","udid":"7B7A3A94-372F-4872-8BD0-F7BC50CA2924","autoAcceptAlerts":true,"unexpectedAlertBehaviour":true},"capabilities":{"alwaysMatch":{"appium:app":"/Users/user.name/Desktop/XXXXX.app","appium:autoAcceptAlerts":true,"appium:automationName":"XCUITest","browserName":"iPhone","appium:deviceName":"iPhone 7","appium:newCommandTimeout":1500,"appium:noReset":false,"platform":"MAC","platformName":"ios","appium:platformVersion":"11.4","appium:udid":"7B7A3A94-372F-4872-8BD0-F7BC50CA2924","unexpectedAlertBehaviour":true,"unhandledPromptBehavior":true,"version":""},"firstMatch":[{}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"app":"/Users/user.name/Desktop/XXXXX.app","noReset":false,"unhandledPromptBehavior":true,"deviceName":"iPhone 7","version":"","platform":"MAC","newCommandTimeout":1500,"platformVersion":"11.4","automationName":"XCUITest","browserName":"iPhone","platformName":"IOS","udid":"7B7A3A94-372F-4872-8BD0-F7BC50CA2924","autoAcceptAlerts":true,"unexpectedAlertBehaviour":true},null,{"alwaysMatch":{"appium:app":"/Users/user.name/Desktop/XXXXX.app","appium:autoAcceptAlerts":true,"appium:automationName":"XCUITest","browserName":"iPhone","appium:deviceName":"iPhone 7","appium:newCommandTimeout":1500,"appium:noReset":false,"platform":"MAC","platformName":"ios","appium:platformVersion":"11.4","appium:udid":"7B7A3A94-372F-4872-8BD0-F7BC50CA2924","unexpectedAlertBehaviour":true,"unhandledPromptBehavior":true,"version":""},"firstMatch":[{}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1539403642546 (09:37:22 GMT+0530 (IST))
[BaseDriver] The capabilities ["platform","unexpectedAlertBehaviour","version"] are not standard capabilities and should have an extension prefix
[Appium] Creating new XCUITestDriver (v2.84.0) session
[Appium] Capabilities:
[Appium]   browserName: iPhone
[Appium]   platform: MAC
[Appium]   platformName: ios
[Appium]   unexpectedAlertBehaviour: true
[Appium]   unhandledPromptBehavior: true
[Appium]   version: 
[Appium]   app: /Users/user.name/Desktop/XXXXX.app
[Appium]   autoAcceptAlerts: true
[Appium]   automationName: XCUITest
[Appium]   deviceName: iPhone 7
[Appium]   newCommandTimeout: 1500
[Appium]   noReset: false
[Appium]   platformVersion: 11.4
[Appium]   udid: 7B7A3A94-372F-4872-8BD0-F7BC50CA2924
[debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"browserNam... and MJSONWP desired capabilities [object Object] were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"browserNam...
[BaseDriver] The following capabilities were provided, but are not recognized by appium: unhandledPromptBehavior, platform, unexpectedAlertBehaviour, version.
[XCUITest] The capabilities 'autoAcceptAlerts' and 'autoDismissAlerts' do not work for XCUITest-based tests. Please adjust your alert handling accordingly.
[BaseDriver] Session created with session id: 7b782b91-6f85-433d-b713-070a891c95f9
[debug] [XCUITest] Current user: 'user.name'
[debug] [XCUITest] Xcode version set to '9.4.1' (tools v9.4.0.0.1.1526532315)
[debug] [XCUITest] iOS SDK Version set to '11.4'
[debug] [BaseDriver] Event 'xcodeDetailsRetrieved' logged at 1539403642636 (09:37:22 GMT+0530 (IST))
[iOSSim] Constructing iOS simulator for Xcode version 9.4.1 with udid '7B7A3A94-372F-4872-8BD0-F7BC50CA2924'
[XCUITest] Determining device to run tests on: udid: '7B7A3A94-372F-4872-8BD0-F7BC50CA2924', real device: false
[BaseDriver] Using local app '/Users/user.name/Desktop/XXXXX.app'
[debug] [BaseDriver] Event 'appConfigured' logged at 1539403642857 (09:37:22 GMT+0530 (IST))
[debug] [XCUITest] Checking whether app '/Users/user.name/Desktop/XXXXX.app' is actually present on file system
[debug] [XCUITest] App is present
[debug] [iOS] Getting bundle ID from app '/Users/user.name/Desktop/XXXXX.app': 'XXX.XXXX.ios'
[debug] [BaseDriver] Event 'resetStarted' logged at 1539403642858 (09:37:22 GMT+0530 (IST))
[XCUITest] Not scrubbing third party app in anticipation of uninstall
[debug] [BaseDriver] Event 'resetComplete' logged at 1539403643079 (09:37:23 GMT+0530 (IST))
[debug] [XCUITest] Starting log capture for iOS Simulator with udid '7B7A3A94-372F-4872-8BD0-F7BC50CA2924', using 'xcrun simctl spawn 7B7A3A94-372F-4872-8BD0-F7BC50CA2924 log stream --style compact'
[debug] [BaseDriver] Event 'logCaptureStarted' logged at 1539403643385 (09:37:23 GMT+0530 (IST))
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[debug] [iOSSim] Matched 1 Simulator cache item for cleanup: /Users/user.name/Library/Developer/CoreSimulator/Devices/7B7A3A94-372F-4872-8BD0-F7BC50CA2924/data/Library/Caches/com.apple.mobile.installd.staging
[debug] [iOSSim] Setting preferences of 7B7A3A94-372F-4872-8BD0-F7BC50CA2924 Simulator to {"ConnectHardwareKeyboard":false}
[debug] [iOSSim] Setting common Simulator preferences to {"ConnectHardwareKeyboard":false}
[debug] [iOSSim] Updated 7B7A3A94-372F-4872-8BD0-F7BC50CA2924 Simulator preferences at '/Users/user.name/Library/Preferences/com.apple.iphonesimulator.plist' with {"DevicePreferences":{"7B7A3A94-372F-4872-8BD0-F7BC50CA2924":{"ConnectHardwareKeyboard":false}},"ConnectHardwareKeyboard":false}
[debug] [iOSSim] The count of running Simulator UI client instances is 1
[iOSSim] Both Simulator with UDID 7B7A3A94-372F-4872-8BD0-F7BC50CA2924 and the UI client are currently running
[debug] [BaseDriver] Event 'simStarted' logged at 1539403643658 (09:37:23 GMT+0530 (IST))
[debug] [XCUITest] Verifying application platform
[debug] [XCUITest] CFBundleSupportedPlatforms: ["iPhoneSimulator"]
[debug] [XCUITest] Reset requested. Removing app with id 'XXX.XXXX.ios' from the device
[debug] [XCUITest] Installing '/Users/user.name/Desktop/XXXXX.app' on Simulator with UUID '7B7A3A94-372F-4872-8BD0-F7BC50CA2924'...
[debug] [XCUITest] The app has been installed successfully.
[debug] [BaseDriver] Event 'appInstalled' logged at 1539403647212 (09:37:27 GMT+0530 (IST))
[XCUITest] Using WDA path: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[debug] [XCUITest] No obsolete cached processes from previous WDA sessions listening on port 8100 have been found
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{n  "value" : {n    "state" : "success",n    "os" : {n      "name" : "iOS",n      "version" : "11.4",n      "sdkVersion" : "11.3"n    },n    "ios" : {n      "simulatorVersion" : "11.4",n      "ip" : "192.168.2.4"n    },n    "build" : {n      "upgradedAt" : "1539327134564",n      "time" : "Oct 12 2018 12:22:23",n      "productBundleIdentifier" : "com.facebook.WebDriverAgentRunner"n    }n  },n  "sessionId" : "163984B3-334E-4054-AB68-99D93F26F976",n  "status" : 0n}"
[XCUITest] Will reuse previously cached WDA instance at 'http://localhost:8100/'. Set the wdaLocalPort capability to a value different from 8100 if this is an undesired behavior.
[debug] [BaseDriver] Event 'wdaStartAttempted' logged at 1539403647303 (09:37:27 GMT+0530 (IST))
[XCUITest] Using provided WebdriverAgent at 'http://localhost:8100/'
[debug] [BaseDriver] Event 'wdaSessionAttempted' logged at 1539403647304 (09:37:27 GMT+0530 (IST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{n  "value" : {n    "state" : "success",n    "os" : {n      "name" : "iOS",n      "version" : "11.4",n      "sdkVersion" : "11.3"n    },n    "ios" : {n      "simulatorVersion" : "11.4",n      "ip" : "192.168.2.4"n    },n    "build" : {n      "upgradedAt" : "1539327134564",n      "time" : "Oct 12 2018 12:22:23",n      "productBundleIdentifier" : "com.facebook.WebDriverAgentRunner"n    }n  },n  "sessionId" : "163984B3-334E-4054-AB68-99D93F26F976",n  "status" : 0n}"

**[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bundleId":"XXX.XXXX.ios","arguments":[],"environment":{},"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}}**

[debug] [JSONWP Proxy] Got response with status 200: {"value":{"sessionId":"91784C9C-3B63-40D3-9335-9C80548E7E68","capabilities":{"device":"iphone","browserName":null,"sdkVersion":"11.4","CFBundleIdentifier":null}},"sessionId":"91784C9C-3B63-40D3-9335-9C80548E7E68","status":0}
[debug] [BaseDriver] Event 'wdaSessionStarted' logged at 1539403968659 (09:42:48 GMT+0530 (IST))
[debug] [BaseDriver] Event 'wdaStarted' logged at 1539403968659 (09:42:48 GMT+0530 (IST))
[XCUITest] Skipping setting of the initial display orientation. Set the "orientation" capability to either "LANDSCAPE" or "PORTRAIT", if this is an undesired behavior.
[debug] [BaseDriver] Event 'orientationSet' logged at 1539403968660 (09:42:48 GMT+0530 (IST))
[Appium] New XCUITestDriver session created successfully, session 7b782b91-6f85-433d-b713-070a891c95f9 added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1539403968660 (09:42:48 GMT+0530 (IST))
[debug] [W3C] Responding to client with driver.createSession() result: {"capabilities":{"webStorageEnabled":false,"locationContextEnabled":false,"browserName":"iPhone","platform":"MAC","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"networkConnectionEnabled":false,"platformName":"ios","unhandledPromptBehavior":true,"unexpectedAlertBehaviour":true,"version":"","app":"/Users/user.name/Desktop/XXXXX.app","autoAcceptAlerts":true,"automationName":"XCUITest","deviceName":"iPhone 7","newCommandTimeout":1500,"noReset":false,"platformVersion":"11.4","udid":"7B7A3A94-372F-4872-8BD0-F7BC50CA2924"}}

尝试使用功能noReset: true运行测试,并且在每次测试之前不要关闭/启动驱动程序:您可以使用driver.launchApp()简单地重新启动它。

最新更新