Skip to content

ValueError: Timeout value connect was <object object at 0x7f7515f84420>, but it must be an int, float or None. #863

@suneel944

Description

@suneel944

The problem

I am getting the above summary as error when trying to execute the appium android automation and below is the code:

def get_driver(self, *, capabilities: dict[str, Any]):
        """Concrete implementation method of fetching android mobile driver

        Args:
            capabilities (dict[str, Any]): android capabilities

        Returns:
            WebDriver: Android driver instance
        """
        from appium.options.android import UiAutomator2Options
        from appium.webdriver import Remote

        # launch android driver
        return Remote(
            self.remote_url,
            options=UiAutomator2Options().load_capabilities(capabilities),
            direct_connection=True,
        )

These are the arguments passed to the method:
self.remote_url = "http://localhost:4725/wd/hub"
capabilities = {'platformName': 'android', 'deviceName': 'Test_AUTO_DEVICE_WEB', 'udid': '96324991560008D', 'autoGrantPermissions': True, 'automationName': 'UiAutomator2', 'browserName': 'Chrome'}

Error:

uaf/factories/driver/concrete_factory/concrete_factory.py:37: in get_mobile_driver
    ).get_mobile_driver(
uaf/factories/driver/concrete_factory/concrete_products/mobile/concrete_mobile_driver.py:66: in get_mobile_driver
    ConcreteAndroidDriver(remote_url).get_driver(capabilities=capabilities)
uaf/factories/driver/concrete_factory/concrete_products/mobile/concrete_android_driver.py:30: in get_driver
    return Remote(
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/appium/webdriver/webdriver.py:234: in __init__
    super().__init__(
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:286: in __init__
    self.start_session(capabilities, browser_profile)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/appium/webdriver/webdriver.py:324: in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:438: in execute
    response = self.command_executor.execute(driver_command, params)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py:290: in execute
    return self._request(command_info[0], url, body=data)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py:311: in _request
    response = self._conn.request(method, url, body=body, headers=headers)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/_request_methods.py:118: in request
    return self.request_encode_body(
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/_request_methods.py:217: in request_encode_body
    return self.urlopen(method, url, **extra_kw)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/poolmanager.py:422: in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/poolmanager.py:303: in connection_from_host
    return self.connection_from_context(request_context)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/poolmanager.py:328: in connection_from_context
    return self.connection_from_pool_key(pool_key, request_context=request_context)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/poolmanager.py:351: in connection_from_pool_key
    pool = self._new_pool(scheme, host, port, request_context=request_context)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/poolmanager.py:265: in _new_pool
    return pool_cls(host, port, **request_context)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/connectionpool.py:196: in __init__
    timeout = Timeout.from_float(timeout)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/util/timeout.py:190: in from_float
    return Timeout(read=timeout, connect=timeout)
../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/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 0x7f337b984850>, 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 0x7f337b984850>, but it must be an int, float or None.

../../../../.local/share/virtualenvs/Test_Auto_Pytest-9CDw6jIY/lib/python3.11/site-packages/urllib3/util/timeout.py:156: ValueError

Environment

  • Appium version (or git revision) that exhibits the issue: Appium-Python-Client 2.9.0, Appium version 1.22.3 (i.e., npm install -g appium)
  • Last Appium version that did not exhibit the issue (if applicable): N/A
  • Desktop OS/version used to run Appium: Ubuntu 22.04.2 LTS
  • Node.js version (unless using Appium.app|exe): 19.7.0
  • Mobile platform/version under test: Android 13
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: Appium CLI

Details

If necessary, describe the problem you have been experiencing in more detail.

Link to Appium Logs

Create a GIST which is a paste of your full Appium logs, and link them here.

Code To reproduce issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions