Closed
Description
What happened?
When using GUI mode I have no issues, I can get any page quickly using driver.get() without any error:
Loading Page Started: https://manos.ca/
Page Loaded in 0.73 seconds. Title: Mano's Restaurant & Lounge in Saskatoon | We Saved You A Spot
Loading Page Started: https://thecanadianbrewhouse.com/locations/saskatoon/
Page Loaded in 2.05 seconds. Title: Saskatoon’s Best Sports Bar | Locations | The Canadian Brewhouse
But when I switch to --headless or --headless=new some pages seem to freeze when loading, and this ends up triggering a TimeoutException. This doesn't happen on all pages, but only on some URLs that seem to have issues with the headless mode. In my example, I show 2 of these URLs that seem to be having issues.
Traceback (most recent call last):
File "D:\Pycharm Projects\Tests\selenium-error-testing.py", line 15, in <module>
driver.get(url)
File "C:\Users\Desktop\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 363, in get
self.execute(Command.GET, {"url": url})
File "C:\Users\AlvDesktopro\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 354, in execute
self.error_handler.check_response(response)
File "C:\Users\Desktop\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 299.926
(Session info: chrome-headless-shell=127.0.6533.101)
In some rare cases, maybe 1 out of 10 times, one of the pages is able to load but takes much longer, over 20 seconds.
Loading Page Started: https://manos.ca/
Page Loaded in 23.59 seconds. Title: Mano's Restaurant & Lounge in Saskatoon | We Saved You A Spot
How can we reproduce the issue?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
urls = ['https://manos.ca/', 'https://thecanadianbrewhouse.com/locations/saskatoon/']
for url in urls:
start_time = time.time()
print("Loading Page Started:", url)
driver.get(url)
print(f"Page Loaded in {round(time.time() - start_time, 2)} seconds. Title:", driver.title)
Relevant log output
Traceback (most recent call last):
File "D:\Pycharm Projects\Tests\selenium-error-testing.py", line 15, in <module>
driver.get(url)
File "C:\Users\Desktop\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 363, in get
self.execute(Command.GET, {"url": url})
File "C:\Users\AlvDesktopro\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 354, in execute
self.error_handler.check_response(response)
File "C:\Users\Desktop\AppData\Local\pypoetry\Cache\virtualenvs\tests-JpSX7oic-py3.12\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 299.926
(Session info: chrome-headless-shell=127.0.6533.101)
Operating System
Windows 10
Selenium version
Python selenium = "4.23.1"
What are the browser(s) and version(s) where you see this issue?
Chrome
What are the browser driver(s) and version(s) where you see this issue?
Version 127.0.6533.101 (Official Build) (64-bit)
Are you using Selenium Grid?
No and Yes, I've tried with both local selenium and remote using Grid and the issue happens in both.