I have a selenium script using Chrome that runs for a very long time.
Eventually, the browser runs out of memory, and I get the "Error code: Out of Memory" page.
The problem is, no error is thrown in Python, so I don't know how to detect when the error has occurred. The code just ends up hanging, usually on a line like
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.timeline-events')).click()
It's only until I manually navigate to another page that I get an error like "selenium.common.exceptions.WebDriverException: Message: disconnected: received Inspector.detached event"
I know I can have the script periodically close and reopen the browser, but I'd rather handle the error directly.
EDIT: Currently, I'm addressing the issue by having the script restart when memory usage gets over 1 GB, but I'd still like to be able to get an actual error thrown.
EDIT 2: I've read over the linked posts and I don't think they address the same issue.
Regarding this post: How to set memory limit for OOM Killer for chrome?
I'm using Windows. The memory limit seems to be imposed by the browser rather than the operating system.
Regarding this post: java.lang.OutOfMemoryError: unable to create new native thread error using ChromeDriver and Chrome through Selenium in Spring boot
My issue is that no exception is being thrown (in Python). Instead, the driver just hangs on the line of code posted above and shows the "Error code: Out of Memory" Chrome page, so I can't catch and handle the error.
Running out of memory is kind of expected, since I'm navigating a SPA for a very long time.