'What is ReadTimeoutError in python selenium?

2022-03-15 16:21:01,230 : POST http://127.0.0.1:34661/session/51dfe287ba054e814c0b664c662330c5/element {"using": "css selector", "value": "[name=\"Submit\"]"}
2022-03-15 16:21:01,311 : http://127.0.0.1:34661 "POST /session/51dfe287ba054e814c0b664c662330c5/element HTTP/1.1" 200 88
2022-03-15 16:21:01,313 : Finished Request
2022-03-15 16:21:01,313 : POST http://127.0.0.1:34661/session/51dfe287ba054e814c0b664c662330c5/element/c526e0ba-1d3b-442f-bbfb-167b1ffd6895/click {"id": "c526e0ba-1d3b-442f-bbfb-167b1ffd6895"}
2022-03-15 16:22:31,335 :
ERROR

2022-03-15 16:22:31,336 : ReadTimeoutError("HTTPConnectionPool(host='127.0.0.1', port=34661): Read timed out. (read timeout=<object object at 0x762b3810>)")

2022-03-15 20:53:25,251 : Line No : 26

The above log shows my selenium automation script's log. In which, I actually clicked a button using the name.

from selenium import webdriver
from access_points import get_scanner
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import WebDriverException

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
chrome_options.add_argument("--no-sandbox")

driver = webdriver.Chrome(options=chrome_options)
driver.implicitly_wait(20) # seconds
driver.get("http://192.168.1.2")
item = driver.find_element_by_name(val)
if item :
    item.click() # Line no 26

This code works sometimes and sometimes not. I was thinking that the button was not loaded at the time of click and hence I put an implicit wait of 10sec. But it is not the reason since it enters the if statement.

What could cause the selenium to raise ReadTimeOutError?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source