LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-01-2012, 06:58 AM   #1
Sukh
LQ Newbie
 
Registered: Aug 2012
Posts: 2

Rep: Reputation: Disabled
Smile 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 07:13 AM. Reason: making more readable
 
Old 08-03-2012, 12:37 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
cron run as a detached process, so it doesn't have a terminal/display to talk to ...
If you search around LQ you may find some sort of work around, but its not designed to use a terminal usually..
 
1 members found this post helpful.
Old 08-10-2012, 05:23 AM   #3
Sukh
LQ Newbie
 
Registered: Aug 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Issue was resolved.
I included statement:
PATH=/usr/bin:://usr/sbin
and it started running fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron-tab issue(Task scheduling) amritpalpathak Linux - Software 4 04-10-2011 04:20 AM
[SOLVED] problem in scheduling script using /etc/cron.d etika Linux - Newbie 2 03-16-2011 08:39 AM
python rsync script runs from shell not from cron beanbox Programming 3 11-18-2009 06:23 PM
Unable to run Python script with cron terminally.confused Linux - Newbie 3 03-08-2009 02:06 PM
PPPD Script problem when cron-scheduling the script andresurzagasti Linux - Networking 0 11-24-2004 02:54 PM


All times are GMT -5. The time now is 10:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration