新手区 [appuim] 搭建好 server 环境后,执行官方 sample 失败,server 端没有 log,好像是新建 session 失败。

TrA_zH · 2017年05月08日 · 最后由 JOJO酱~ 回复于 2017年05月09日 · 2527 次阅读

在 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()

共收到 3 条回复 时间 点赞

我在网上查了很多,到连接这里报错,确实不知道什么原因,openssl 也更新过了

已解决问题,使用 appium server 的时候,不能使用全局代理

TrA_zH 回复

请问不能使用全局代理是什么意思?需要在哪里修改吗

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册