appium Timeout value connect was xxx but it must be an int, float or None

ValueError(ValueError: Timeout value connect was <object object at 0x0000015ABD694FD0>, but it must be an int, float or None.
Process finished with exit code 1

完整错误示例

ERROR                     [100%]
test setup failed
self = <class 'tests.test_appium_clock.TestClock'>

    def setup_class(self):
        caps = {}
        caps["platformName"] = "android"
        caps["appium:ensureWebviewsHavePages"] = True
        caps["appium:nativeWebScreenshot"] = True
        caps["appium:newCommandTimeout"] = 3600
        caps["appium:connectHardwareKeyboard"] = True
>       self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)

test_appium_clock.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../venv/lib/python3.10/site-packages/appium/webdriver/webdriver.py:234: in __init__
    super().__init__(
../venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:286: in __init__
    self.start_session(capabilities, browser_profile)
../venv/lib/python3.10/site-packages/appium/webdriver/webdriver.py:324: in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
../venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:438: in execute
    response = self.command_executor.execute(driver_command, params)
../venv/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py:290: in execute
    return self._request(command_info[0], url, body=data)
../venv/lib/python3.10/site-packages/selenium/webdriver/remote/remote_connection.py:311: in _request
    response = self._conn.request(method, url, body=body, headers=headers)
../venv/lib/python3.10/site-packages/urllib3/_request_methods.py:118: in request
    return self.request_encode_body(
../venv/lib/python3.10/site-packages/urllib3/_request_methods.py:217: in request_encode_body
    return self.urlopen(method, url, **extra_kw)
../venv/lib/python3.10/site-packages/urllib3/poolmanager.py:422: in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
../venv/lib/python3.10/site-packages/urllib3/poolmanager.py:303: in connection_from_host
    return self.connection_from_context(request_context)
../venv/lib/python3.10/site-packages/urllib3/poolmanager.py:328: in connection_from_context
    return self.connection_from_pool_key(pool_key, request_context=request_context)
../venv/lib/python3.10/site-packages/urllib3/poolmanager.py:351: in connection_from_pool_key
    pool = self._new_pool(scheme, host, port, request_context=request_context)
../venv/lib/python3.10/site-packages/urllib3/poolmanager.py:265: in _new_pool
    return pool_cls(host, port, **request_context)
../venv/lib/python3.10/site-packages/urllib3/connectionpool.py:196: in __init__
    timeout = Timeout.from_float(timeout)
../venv/lib/python3.10/site-packages/urllib3/util/timeout.py:190: in from_float
    return Timeout(read=timeout, connect=timeout)
../venv/lib/python3.10/site-packages/urllib3/util/timeout.py:119: in __init__
    self._connect = self._validate_timeout(connect, "connect")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'urllib3.util.timeout.Timeout'>
value = <object object at 0x109414cc0>, name = 'connect'

    @classmethod
    def _validate_timeout(cls, value: _TYPE_TIMEOUT, name: str) -> _TYPE_TIMEOUT:
        """Check that a timeout attribute is valid.
    
        :param value: The timeout value to validate
        :param name: The name of the timeout attribute to validate. This is
            used to specify in error messages.
        :return: The validated and casted version of the given value.
        :raises ValueError: If it is a numeric value less than or equal to
            zero, or the type is not an integer, float, or None.
        """
        if value is None or value is _DEFAULT_TIMEOUT:
            return value
    
        if isinstance(value, bool):
            raise ValueError(
                "Timeout cannot be a boolean value. It must "
                "be an int, float or None."
            )
        try:
            float(value)
        except (TypeError, ValueError):
>           raise ValueError(
                "Timeout value %s was %s, but it must be an "
                "int, float or None." % (name, value)
            ) from None
E           ValueError: Timeout value connect was <object object at 0x109414cc0>, but it must be an int, float or None.

../venv/lib/python3.10/site-packages/urllib3/util/timeout.py:156: ValueError
、

如果遇到这类的错误,就对selenium进行适当的版本降级,比如把selenium降低到3.8

1 Like

大佬牛逼,这个问题困扰我两三天了,找遍全网没找到相同情况的。按你方法成功解决了,pycharm太坑了,装appium-python-client自动把selenium装了最新版的

没有什么测试难题是霍格沃兹测试开发学社解决不了的 :slight_smile:

appium 测试微信小程序。 webview页面出现,原生弹框。怎么解决?

求助【微信小程序】混合型,图中弹框是 原生的,怎么定位上面的“确定”按钮?

大佬牛逼。解决了