如何通过python编码启动appium servie并运行pytest脚本

时间:2019-04-30 09:19:45

标签: python appium python-appium

我尝试过 来自appium.webdriver.appium_service import AppiumService

appAppium = AppiumService()

appAppium.start()

但是代码在Windows env中引发错误。

  

_____________________设置TestLogin.test_C8275_Verify_User_Can_Enter_Valid_Password _____________________时出错

self = <urllib3.connection.HTTPConnection object at 0x03B34A30>

def _new_conn(self):
    """ Establish a socket connection and set nodelay settings on it.

    :return: New socket connection.
    """
    extra_kw = {}
    if self.source_address:
        extra_kw['source_address'] = self.source_address

    if self.socket_options:
        extra_kw['socket_options'] = self.socket_options

    try:
        conn = connection.create_connection(
           (self.host, self.port), self.timeout, **extra_kw)
  

d:\ python \ lib \ site-packages \ urllib3 \ connection.py:141:

     
address = ('127.0.0.1', 4723), timeout = <object object at 0x00734BA0>, source_address = None
socket_options = [(6, 1, 1)]

def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                      source_address=None, socket_options=None):
    """Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    """

    host, port = address
    if host.startswith('['):
        host = host.strip('[]')
    err = None

    # Using the value from allowed_gai_family() in the context of getaddrinfo lets
    # us select whether to work with IPv4 DNS records, IPv6 records, or both.
    # The original create_connection function always returns all records.
    family = allowed_gai_family()

    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        sock = None
        try:
            sock = socket.socket(af, socktype, proto)

            # If provided, set socket level options before connecting.
            _set_socket_options(sock, socket_options)

            if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
                sock.settimeout(timeout)
            if source_address:
                sock.bind(source_address)
            sock.connect(sa)
            return sock

        except socket.error as e:
            err = e
            if sock is not None:
                sock.close()
                sock = None

    if err is not None:
       raise err
  

d:\ python \ lib \ site-packages \ urllib3 \ util \ connection.py:83:

如果我使用os.call("appium") 代码在appium启动后挂起。

在appium启动之后,我希望appium在后台运行,而我的python android脚本sun在运行。

0 个答案:

没有答案