EDIT: While the linked "duplicate" post is helpful in explaining why this error page is encountered and how to avoid it, it doesn't seem to completely prevent this error or explain how to catch and handle it in code. Even if you increase the memory in /dev/shm, it seems like it will eventually run out of memory anyway?
I posted this question before, but it was marked as a duplicate, despite the fact that the linked posts didn't address my issue.
Chrome out of memory in selenium - no error thrown
The linked posts both refer to actual errors being thrown in code, whereas all I get is a chrome error page that doesn't throw any errors in Python. This means that my code hangs perpetually on selenium-executed Javascript.
My original question/problem:
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.
Chrome out of memory error 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, to avoid making my code too messy.
Currently, I'm addressing the issue by having the script restart when memory usage gets over 1 GB, but the solution isn't perfect.