I have a very simple python code that has stopped working recently only when running in a cron.
basically, this is how it began:
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver.firefox.options import Options
display = Display(visible=0, size=(1000, 1000))
display.start()
url = "https://www.exemple.com/admin"
opts= Options()
opts.headless = True
driver = webdriver.Firefox(options=opts)
driver.get(url)
This raise an error :
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
The geckodriver logs are :
1586945401577 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileYPmycq"
*** You are running in headless mode.
1586945401858 addons.webextension.doh-rollout@mozilla.org WARN Loading extension 'doh-rollout@mozilla.org': Reading manifest: Invalid extension permission: networkStatus
1586945401873 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1586945401873 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
1586945401873 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1586945401873 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
Exiting due to channel error.
Exiting due to channel error.
Geckodriver version: 0.26 Firefox version: 76.0b4 Python version: 3.6 Selenium version: 3.14.1
Therefor, I think there is no incompatibility problems. Gecko is executable for all users, and is located in /usr/bin/.
I checked all information find here WebDriverException: Message: invalid argument: can't kill an exited process with GeckoDriver, Selenium and Python on RaspberryPi3
I also tried to launch firefox alone from terminal, by adding DISPLAY:=10 and that worked.
The script work fine from terminal, but once in the CRONTAB, I have the error above.
Also, I killed all firefox process before running.