[Fixed] getting error when I run selenium script Value Error: Timeout value connect was <object object at 0x000002A40BE37F80> – Timeout

by
Ali Hasan
timeout valueerror

Quick Fix: Downgrade selenium to version 4.9.0 using the command: pip install selenium==4.9.0.

The Problem:

You are trying to use Selenium to open the Amazon website in a Chrome browser but receiving a ‘ValueError: Timeout value connect was <object object at 0x000002A40BE37F80>, but it must be an int, float or None’ error. The cause of this error is that the timeout value provided for the connection is not valid. The timeout value should be of type int or float, but instead, an object is being passed.

The Solutions:

Solution 1: Downgrading the library versions

The error occurs due to the mismatched versions of `selenium` and `urllib3`. Update `selenium` to version `4.9.1` and `urllib3` to version `1.26.8` to resolve the issue.

Solution 2: Using Service

In this approach, we can prevent the error by using WebDriver Service, which is a class in Selenium that allows us to control the browser driver. By passing the executable path to the “service” parameter, we can avoid direct interaction with the browser driver and potential issues with timeout values.

Here's an example of using the “service” parameter:

from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(service=webdriver.chrome.service.Service(executable_path="C:\\Users\\HP\\Desktop\\webdriver\\chromedriver.exe"))

Solution 3: Install or Update requests library

The error is caused by the fact that your `requests` library is out of date. To fix it, you need to install or update the library by running the following command in your terminal or CMD:

pip install --upgrade requests

Q&A

What’s the cause of the error ‘ValueError: Timeout value connect was <object object at 0x000002A40BE37F80>, but it must be an int, float or None’ using selenium?

selenium versions after 4.9.1 are most likely to cause this issue.

How to fix timeout error when using a selenium webdriver?

Try driver = webdriver.Chrome(service=webdriver.chrome.service.Service(executable_path=&lt;Your Webdriver Path&gt;))

What are the possible solutions to the ‘ValueError: Timeout value connect was <object object at 0x000002A40BE37F80>, but it must be an int, float or None’ error when using selenium?

Update to selenium=4.9.0, install or update the ‘requests’ library.

Video Explanation:

The following video, titled "How To Fix Chrome Browser Launching Issue In WebdriverIO ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

HOW TO FIX SELENIUM CHROME WEB DRIVER ERROR | July 20,2023. Mr Fugu Data ... How To Execute Selenium Scripts On Already Opened Browser. Mukesh ...