Issue with cron scheduling python script which includes webdriver testcase
Hi,
what am i trying to do?
Test a web page using selenium webdriver .python code is working fine when run from terminal.
problem comes when i use crontab to do the same.
These are the files.:
# crontab file :
crontab -l
49 12 * * * /home/sukhwinder/scheduler.sh
#file "scheduler.sh" :
#!/bin/sh
export DISPLAY=:0
cd /home/sukhwinder
python mainpro.py
# file "mainpro.py" :
#!/bin/bash
import time
import sys
import os
def main():
os.system('python /home/sukhwinder/Test_enabling_personal_blacklist.py')
time.sleep(10)
if __name__ == '__main__':
main()
#the error mailed by cron in /var/mail/root file is :
E
======================================================================
ERROR: test_enabling_personal_blacklist (__main__.EnablingPersonalBlacklist)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sukhwinder/Test_enabling_personal_blacklist.py", line 9, in setUp
self.driver=webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 81, in _wait_until_connectable
self._get_firefox_output())
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: No protocol specified\nError: cannot open display: :0\n'
----------------------------------------------------------------------
Ran 1 test in 1.093s
FAILED (errors=1)
I don't know what is this error message suggesting.....please help
Last edited by Sukh; 08-01-2012 at 08:13 AM.
Reason: making more readable
|