Solution if you crash when using selenium on heroku

Solution if you crash when using selenium on heroku

Introduction

For those who use selenium on heroku, we have described the solution in case of crash.

Occurrence event

I got the following error when running selenium on heroku.

Running python manage.py task on ⬢ xxxxx... up, run.9999 (Hobby)
Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: headless chrome=81.0.4044.129)

Solution

Upon examination, it seems to be a crash due to lack of memory. Therefore, it seems that you should take measures to save memory of selenium so as not to run out of memory.

1. Add an argument to save memory to the argument of selenium

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--remote-debugging-port=9222')
driver = webdriver.Chrome(settings.CHROME_PATH, options=options)

2. Make the screen size as small as possible

driver.set_window_size(950, 800)

reference

How do I prevent headless Chromium from crashing? - Heroku Help https://help.heroku.com/DOB4Y0I4/how-do-i-prevent-headless-chromium-from-crashing

Suddenly a mysterious error in Rspec-Qiita https://qiita.com/mishitoshi/items/3ca5a9a26ceb7e2cf034

Selenium::WebDriver::Error::NoSuchDriverError - Today I Learned https://selleo.com/til/posts/mxkjoppuxm-seleniumwebdrivererrornosuchdrivererror

Recommended Posts

Solution if you crash when using selenium on heroku
If you get stuck when building pycocoapi on Windows
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
When using if and when using while
A solution when you can't start project Django on Windows
Checkpoint when you get hooked on LINE parrot return bot on Heroku
# Solution when pip install gives an error when using Anaconda on Windows 10
Articles to see if rejected when git push heroku master on Heroku
Favicon placement (when using Python, Flask, Heroku)
Get Twitter bookmarks on CentOS using Selenium
Error, warning when using TensorFlow on Mac
When you stumble on uWSGI's quick start
There are times when you can shorten the if statement using max · min
Error that occurred in OpenCV3 and its solution Precautions when using OpenCV3 on Mac
CPU usage is 100% when using pygame on Ubuntu 16.04
A addictive story when using tensorflow on Android
Solution if elasticsearch-curator throws DistributionNotFound error on EC2
Until you use PhantomJS with Python on Heroku
What are you using when testing with Python?
What to do if you don't want to use Japanese column names when using ortoolpy.logistics_network