Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
suneel944 opened this issue May 10, 2023 · 11 comments

Comments

@suneel944
Copy link

suneel944 commented May 10, 2023

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

@mykola-mokhnach
Copy link
Contributor

@KazuCocoa Shall we update the implementation of _get_connection_manager for AppiumConnection?
I can observe several things being changed there in the parent class

@KazuCocoa
Copy link
Member

oh... i see

@KazuCocoa
Copy link
Member

I wonder if this was since selenium webdriver v4.9.1 (by urllib3 update). (the connection manager stuff was actually more old one tho)

@KazuCocoa
Copy link
Member

I confirmed pip install selenium==4.9.0 could be a workaround for this. so urllib3 update since 4.9.1 caused this (as the main cause)

@Asiffarooq93
Copy link

This works for me, thanks

@suneel944
Copy link
Author

I checked with version 4.9.0 it is working. When can we expect a fix release in pypi for this as this a blocker if any body using the selenium version > 4.9.0

@KazuCocoa
Copy link
Member

will do it today

@KazuCocoa
Copy link
Member

2.10.0 has this fix as well.

@rethisha
Copy link

I have updated to the latest of selenium . Still same isse. can someone share the steps to resolve the issue

@2110883662212
Copy link

@KazuCocoa Shall we update the implementation of _get_connection_manager for AppiumConnection? I can observe several things being changed there in the parent class

Thanks Brother

@Chengfenghuaxia
Copy link

我也遇到了同样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants