2

I have the following environement

Ubuntu 14.04 LTS under ESXi Python, Selenium webdriver, Xvfb

My script runs just fine if I run it manually, but got stuck when I put the script in the crontab. I have used the export Display correctly and the firefox process starts however the browser just greys out and gets stuck only when the crontab starts the process. If I run it manually everything is fine. It even works via telnet if I used the code below:

display = Display(visible=0, size=(1024,768))
display.start()
<CODE>
display.stop()
ucipass
  • 923
  • 1
  • 8
  • 21
  • 1
    When you run via crontab, your shell startup script isn't run, so it doesn't have access to the `DISPLAY` environment variable that you get when you login normally. – Barmar May 01 '14 at 04:20
  • But the scripts starts and if I do not give the script the DISPLAY variable the browser appears on the desktop, after that when the script continues after the first automated click just goes grey and does not do anything. I have spent countless hours on this and was wondering if anyone with Selenium/Webdriver experience could give me a hint. – ucipass May 01 '14 at 12:11
  • I actually figured this out and the problem was that the script was not starting with the correct shell variable. – ucipass Nov 07 '14 at 17:24

2 Answers2

0

It's not the best solution, but it helps me solve this problem. Instead of firefox, I use Chrome. It doesn't stuck when I put scipt in the crontab.

Here is the tutorial how to get work chromedriver with Chrome/Chromium: Running webdriver chrome with Selenium

Community
  • 1
  • 1
0

I experienced this problem and the fix, for me at least, was to set the HOME variable in the crontab to the path of the home directory of the user that the cronjob was being run as. It was previously being set to '/'.

nedned
  • 3,552
  • 8
  • 38
  • 41