自从 Xcode 升级到 8 后,测试环境和运行测试脚本中遇到的各种各样的问题至今没有彻底解决。作为一个菜鸟,向各位有经验的同仁们请教两个报错问题,求指教。

我的测试环境基本情况是:

MacOS Sierra 10.12/ Xcode 8.1/ Appium 1.6.2/ python2.7

脚本如下:

#!/usr/bin/env python
# -*-coding:utf-8-*-

import unittest
from time import sleep
from appium import webdriver
from loginpage import login

class Testfunction(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        self.driver.close_app()       ##对这一行报错:AttributeError: 'Testfunction' object has no attribute 'driver'
        self.driver.quit()

    def openApplication(self,time):
        desired_caps = {}
        desired_caps['automationName'] = 'XCUITest'
        desired_caps['appium-version'] = '1.6.2'
        desired_caps['platformName'] = 'iOS'
        desired_caps['platformVersion'] = '10.1'
        desired_caps['deviceName'] = 'iPhone SE'
        desired_caps['app'] = os.path.abspath('/Users/nicole/Desktop/***.app')
        self.driver=webdriver.Remote('http://0.0.0.0:4723/wd/hub',desired_caps)
        sleep(30)

    def test_login(self):
        self.openApplication(60)                  ##对这一行报错:BadStatusLine: ''      
        login.is_LoginPage(self.driver)
        ......
        ......


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

如上,所报错误标于脚本中。另外我测试的软件包是开发打包的.app 后缀的 debug 包,测试脚本运行时,在模拟器上显示的现象是该 app 启动后闪退。我手动在模拟器上点击启动该 app 时,也是出现闪退的现象。(但这个 app 之前有被成功手动启动过)

Appium log 如下:

[debug] [WebDriverAgent] Sim: Dec 13 19:59:28 nicoledeMac-mini XCTRunner[9390]: Enqueue Failure: UI Testing Failure - '<XCUIApplicationImpl: 0x608000228820 com.wh.campus>' App state is still not running active, state = XCApplicationStateNotRunning /usr/local/lib/node_modules/appium/node_modules/.2.4.2@appium-xcuitest-driver/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 35 1
[debug] [JSONWP Proxy] Got response with status 200: {"value":"Failed to launch com.wh.campus application","sessionId":"453AFCA9-E113-476C-A472-5DF607CBD9BF","status":13}
[debug] [XCUITest] Unable to start WebDriverAgent session: An unknown server-side error occurred while processing the command. Original error: Failed to launch com.wh.campus application
[XCUITest] UnknownError: An unknown server-side error occurred while processing the command. Original error: Failed to launch com.wh.campus application
    at errorFromCode (../../../lib/mjsonwp/errors.js:398:10)
    at XCUITestDriver.callee$0$0$ (../../../lib/commands/proxy-helper.js:22:11)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
 { UnknownError: An unknown server-side error occurred while processing the command. Original error: Failed to launch com.whmx.campus application
    at errorFromCode (../../../lib/mjsonwp/errors.js:398:10)
    at XCUITestDriver.callee$0$0$ (../../../lib/commands/proxy-helper.js:22:11)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37) jsonwpCode: 13 }
[debug] [JSONWP Proxy] Proxying [DELETE /session/ffab561e-7167-4233-a2ea-327678ac94bd] to [DELETE http://localhost:8100/session/453AFCA9-E113-476C-A472-5DF607CBD9BF] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\n  \"value\" : {\n\n  },\n  \"sessionId\" : \"E645387C-B99C-4506-93CA-442701B8FC80\",\n  \"status\" : 0\n}"
[XCUITest] Shutting down sub-processes
[XCUITest] Shutting down xcodebuild process (pid 9372)
[XCUITest] xcodebuild exited with code 'null' and signal 'SIGTERM'
[XCUITest] Shutting down Logger process (pid 9377)
[XCUITest] Simulator log exited with code 'null'

之前看到社区有人发帖提了相似的问题:https://testerhome.com/topics/6270 ,但因为格式问题帖子被屏蔽。网上搜索了一些解决方法,都没能解决问题。在这里,希望有大神能指导,也希望遇到相同问题的童鞋能一起讨论讨论,感激不尽。


↙↙↙阅读原文可查看相关链接,并与作者交流