unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium

Solution 1:

Though you see the error as:

Error occurred while deleting cookies from web browser!
b'Message: invalid session id\n  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)\n'

The main exception is:

selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed

Your code trials would have given us some clues what going wrong.


Solution

There are diverse solution to this issue. However as per UnknownError: session deleted because of page crash from tab crashed this issue can be solved by either of the following solutions:

  • Add the following chrome_options:

    chrome_options.add_argument('--no-sandbox')         
    
  • Chrome seem to crash in Docker containers on certain pages due to too small /dev/shm. So you may have to fix the small /dev/shm size.

  • An example:

    sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
    
  • It also works if you use -v /dev/shm:/dev/shm option to share host /dev/shm

  • Another way to make it work would be to add the chrome_options as --disable-dev-shm-usage. This will force Chrome to use the /tmp directory instead. This may slow down the execution though since disk will be used instead of memory.

    chrome_options.add_argument('--disable-dev-shm-usage')        
    

from tab crashed

from tab crashed was WIP(Work In Progress) with the Chromium Team for quite some time now which relates to Linux attempting to always use /dev/shm for non-executable memory. Here are the references :

  • Linux: Chrome/Chromium SIGBUS/Aw, Snap! on small /dev/shm
  • Chrome crashes/fails to load when /dev/shm is too small, and location can't be overridden
  • As per Comment61#Issue 736452 the fix seems to be have landed with Chrome v65.0.3299.6

Reference

You can find a couple of relevant discussions in:

  • org.openqa.selenium.SessionNotCreatedException: session not created exception from tab crashed error when executing from Jenkins CI server

Solution 2:

In case someone is facing this problem with docker containers:

use the flag --shm-size=2g when creating the container and the error is gone. This flag make the container to use the host's shared memory.

Example

$ docker run -d --net gridNet2020 --shm-size="2g" -e SE_OPTS="-browser applicationName=zChromeNodePdf30,browserName=chrome,maxInstances=1,version=78.0_debug_pdf" -e HUB_HOST=selenium-hub-3.141.59 -P -p 5700:5555 --name zChromeNodePdf30 -v /var/lib/docker/sharedFolder:/home/seluser/Downloads selenium/node-chrome:3.141.59-xenon

Source: https://github.com/SeleniumHQ/docker-selenium

Solution 3:

I was getting the following error on my Ubuntu server:

selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash from tab crashed (Session info: headless chrome=86.0.4240.111) (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 5.4.0-1029-aws x86_64)

It turned out the the cause of the error was insufficient disk space on the server and the solution was to extend my disk space. You can check this question for more information.