Macaca iOS 真机 通过 unittest 执行多条用例,在执行到第二条的时候,一直报错 socket hang up

linpengcheng · 2017年05月26日 · 最后由 linpengcheng 回复于 2017年05月26日 · 2020 次阅读

macaca 升级到了最新版 ios 驱动也是最新版,在执行脚本的时候,真机运行,第一条 case 可以正常执行,但是到第二条 case 的时候,就一直报 socket hang up 的错误了。
有谁也遇到这个问题吗?

python 脚本代码如下:

class mydemotest(unittest.TestCase):

    def setUp(self):
        self.driver = WebDriver(desired_caps, server_url)
        self.driver.init()
        sleep(2)

    def tearDown(self):
        self.driver.quit()

    def test_login(self):
        '''登录'''
        self.driver .element_by_xpath('//XCUIElementTypeTextField[1]').send_keys('中文+Test+12345678')
        self.driver .element_by_xpath('//XCUIElementTypeSecureTextField[1]').send_keys('111111')
        self.driver .element_by_name('Done').click()
        self.driver .element_by_name('Login').click()
        sleep(1)

    def test_list(self):
        '''进入Home-List '''
        self.driver.element('name', 'PERSONAL').click()
        self.driver.element('name', 'HOME').click()
        self.driver.element('xpath', '//*[@name="list"]').click()
        self.driver.back()
        sleep(2)


if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(mydemotest('test_login'))
    suite.addTest(mydemotest('test_list'))
    runner = unittest.TextTestRunner()
    runner.run(suite)

报错如下:

>> xctestwd start with port: 8901
>> xctest-client.js:226:14 [master] pid:7570 xcode version: 8.3.2
>> XCTestWD version: 1.0.25
>> xctest-client.js:174:14 [master] pid:7570 2017-05-26 10:07:43.949 xcodebuild[7640:428419]  IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
/Users/test/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Logs/Test/E2A64093-9548-43C4-8650-A352CE91FF36/Session-XCTestWDUITests-2017-05-26_100743-g6qbga.log

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 2017-05-26 10:07:43.950 xcodebuild[7640:428416] [MT] IDETestOperationsObserverDebug: (D34C8E23-F368-463C-9B71-A149AFD7D8EE) Beginning test session XCTestWDUITests-D34C8E23-F368-463C-9B71-A149AFD7D8EE at 2017-05-26 10:07:43.950 with Xcode 8E2002 on target <DVTiOSDevice: 0x7f890ca023c0> {
        deviceSerialNumber:         F2MNRA0NG5QR
        identifier:                 ef984ea60feca3c38c11d49b16f77bb01934f610
        deviceClass:                iPhone
        deviceName:                 iPhonelin
        deviceIdentifier:           ef984ea60feca3c38c11d49b16f77bb01934f610
        productVersion:             10.3.2
        buildVersion:               14F89
        deviceSoftwareVersion:      10.3.2 (14F89)
        deviceArchitecture:         arm64
        deviceTotalCapacity:        12067799040
        deviceAvailableCapacity:    533405696
        deviceIsTransient:          NO
        ignored:                    NO
        deviceIsBusy:               NO
        deviceIsActivated:          YES
        deviceActivationState:      Activated
        isPasscodeLocked:           NO
        deviceType:                 <DVTDeviceType:0x7f8909fbe860 Xcode.DeviceType.iPhone>
        supportedDeviceFamilies:    (
    1
)
        applications:              (null)
        provisioningProfiles:      (null)
        activityProgress:          -2
        activityTitle:             
        hasInternalSupport:        NO
        isSupportedOS:             YES
        developerDiskMountError:   (null)
(null)
    bootArgs:                  <unavailable>
        } (10.3.2 (14F89))

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/2903981e6682c26dcb0cb9a4791557fc/ef984ea60feca3c38c11d49b16f77bb01934f610/XCTestWDUITests-Runner.app
state->new_bundle: /Users/test/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Build/Products/Debug-iphoneos/XCTestWDUITests-Runner.app
state->dst_bundle: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.Revx77/XCTestWDUITests-Runner.app_sparse.ipa/Payload//XCTestWDUITests-Runner.app, binaryDiff flag: FALSE
    dst_ipa: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.Revx77/XCTestWDUITests-Runner.app_sparse.ipa

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 __MDMDirectoryDiff_block_invoke.37:1473 calling writeDictToFile with: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.Revx77/XCTestWDUITests-Runner.app_sparse.ipa/ManifestCache.plist

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.Revx77/XCTestWDUITests-Runner.app_sparse.ipa/ManifestCache.plist

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/10dbca5f7dadf4d0b6e2950a9f6fe3f7/ef984ea60feca3c38c11d49b16f77bb01934f610/XCTestWD.app
state->new_bundle: /Users/test/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Build/Products/Debug-iphoneos/XCTestWD.app
state->dst_bundle: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWD.app.kzVRPu/XCTestWD.app_sparse.ipa/Payload//XCTestWD.app, binaryDiff flag: FALSE
    dst_ipa: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWD.app.kzVRPu/XCTestWD.app_sparse.ipa

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 __MDMDirectoryDiff_block_invoke.37:1473 calling writeDictToFile with: /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWD.app.kzVRPu/XCTestWD.app_sparse.ipa/ManifestCache.plist

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> xctest-client.js:174:14 [master] pid:7570 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/f8/3p2vqj391jv3_0zsbbn1x1wr0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWD.app.kzVRPu/XCTestWD.app_sparse.ipa/ManifestCache.plist

>> xctest-client.js:175:14 [master] pid:7570 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj
>> proxy.js:55:14 [master] pid:7570 Proxy: /wd/hub/session:POST to http://127.0.0.1:8901/wd/hub/session:POST with body: {"desiredCapabilities":{"bundleId":"linpc.ios-app-bootstrap","platformVersion":"10.3","platformName":"iOS"}}
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> proxy.js:61:22 [master] pid:7570 xctest client proxy error with: Error: socket hang up
>> xctest-client.js:249:14 [master] pid:7570 Fail to start xctest: Error: socket hang up
>> xctest-client.js:257:14 [master] pid:7570 killing deviceLogProc pid: 7637
>> xctest-client.js:262:14 [master] pid:7570 killing runnerProc pid: 7640
>> xctest-client.js:268:14 [master] pid:7570 killing iproxyProc pid: 7639
>> responseHandler.js:54:12 [master] pid:7570 Send Error Respone to Client: Error: socket hang up
>> responseHandler.js:60:14 [master] pid:7570 Error: socket hang up
    at createHangUpError (_http_client.js:254:15)
    at Socket.socketOnEnd (_http_client.js:346:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

  Error: socket hang up
      at createHangUpError (_http_client.js:254:15)
      at Socket.socketOnEnd (_http_client.js:346:23)
      at emitNone (events.js:91:20)
      at Socket.emit (events.js:185:7)
      at endReadableNT (_stream_readable.js:974:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

>> xctest-client.js:147:16 [master] pid:7570 deviceconsole exit with code: null, signal: SIGKILL
>> xctest-client.js:213:14 [master] pid:7570 iproxy exit with code: null, signal: SIGKILL
>> xctest-client.js:185:14 [master] pid:7570 xctest client exit with code: null, signal: SIGKILL


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 1 条回复 时间 点赞
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册