Thank you for the additional details. With Selenium 4.18.1 and Chrome headless mode, especially when dealing with many elements, there are a few specific approaches we can take:
- Use the new Selenium 4 Headless Mode syntax (it's more stable):
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless=new") # New headless mode for Chrome