在 macOS sierra 上用源码搭建的 appuim server,经过 appium-doctor,启动成功,用 Python 执行官方 sample,server 端无日志,sample 执行报错。

个人分析是新建 seesion 失败,并未进入测试单元。并不知其原因,希望与各位大神交流,接受指导。

sample 报错信息如下:

Error
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 322, in run
self.setUp()
File "/Users/TrA_zH/PycharmProjects/autoTest_Appium_python/MyTestDrive.py", line 18, in setUp
'deviceName': 'iPhone Simulator'
File "build/bdist.macosx-10.12-intel/egg/appium/webdriver/webdriver.py", line 36, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "/Library/Python/2.7/site-packages/selenium-3.4.1-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 98, in init
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium-3.4.1-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Python/2.7/site-packages/selenium-3.4.1-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 250, in execute
response = self.command_executor.execute(driver_command, params)
File "/Library/Python/2.7/site-packages/selenium-3.4.1-py2.7.egg/selenium/webdriver/remote/remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "/Library/Python/2.7/site-packages/selenium-3.4.1-py2.7.egg/selenium/webdriver/remote/remote_connection.py", line 526, in _request
resp = opener.open(request, timeout=self._timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1200, in do_open
r = h.getresponse(buffering=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1132, in getresponse
response.begin()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 54] Connection reset by peer

drive 代码如下:

import unittest
import os
from appium import webdriver


class MyTest(unittest.TestCase):

    def setUp(self):
        path = '/Users/TrA_zH/Library/Developer/Xcode/DerivedData/TestApp-ccgdetpwaedffybjvwfmpinqhent/Build/Products/Debug-iphonesimulator/TestApp.app'
        app = os.path.join(os.path.dirname(__file__), path)
        app = os.path.abspath(app)
        self.driver = webdriver.Remote(
            command_executor='http://127.0.0.1:4723/wd/hub',
            desired_capabilities={
                'app': app,
                'platformName': 'ios',
                'platformVersion': '9.3',
                # device: iPhone Simulator, iPad Simulator, iPhone Retina 4-inch, Android Emulator, Galaxy S4
                'deviceName': 'iPhone Simulator'
            })

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


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