Linux Mint, Ubuntu, Python, Firefox, Selenium, and Webdriver – Headless Edition

I have a few browser automation tasks set up to run using cron on my home NAS (Ubuntu / Linux Mint 17), but ran into trouble with Selenium’s webdriver throwing exceptions due to my NAS being headless.   There is a very simple workaround for this problem – create a bash/shell script that you will call from cron, give it the proper permissions, and format it as such:

export DISPLAY=:0.0
python /home/yourhomedir/scripts/

That’s it.  Now your Selenium automation will run headless with no additional modification to your existing Python/Selenium/Webdriver code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.