running selenium tests with crontab

1,247 views
Skip to first unread message

Davina Armstrong

unread,
Jan 29, 2010, 2:33:51 PM1/29/10
to Selenium Users
I've got a script that launches selenium-server, runs a bunch of
tests, and shuts down selenium-server. It works great from the
command line, but when I try to run it with crontab, I get the error
below. What is meant by "explicitly specify a path to Firefox 3"?
Where do I specify it?

Thanks,
Davina

Could not start Selenium session: Failed to start new browser session:
java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to
your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin

Neha Chachra

unread,
Jan 29, 2010, 4:22:36 PM1/29/10
to seleniu...@googlegroups.com
Can you paste here the contents of your crontab here?

Thanks,
-Neha


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Davina Armstrong

unread,
Jan 29, 2010, 4:49:02 PM1/29/10
to Selenium Users
[biit@drover bvt]$ crontab -l
0 7 * * * /home/biit/qa/bvt/test.sh
7 12 29 1 * /home/biit/qa/bvt/test.sh


On Jan 29, 1:22 pm, Neha Chachra <neha.chac...@gmail.com> wrote:
> Can you paste here the contents of your crontab here?
>
> Thanks,
> -Neha
>

> On Fri, Jan 29, 2010 at 11:33 AM, Davina Armstrong <dstaras...@gmail.com>wrote:
>
> > I've got a script that launches selenium-server, runs a bunch of
> > tests, and shuts down selenium-server.  It works great from the
> > command line, but when I try to run it with crontab, I get the error
> > below.  What is meant by "explicitly specify a path to Firefox 3"?
> > Where do I specify it?
>
> > Thanks,
> > Davina
>
> > Could not start Selenium session: Failed to start new browser session:
> > java.lang.RuntimeException: Firefox 3 could not be found in the path!
> > Please add the directory containing ''firefox-bin' or 'firefox'' to
> > your PATH environment
> > variable, or explicitly specify a path to Firefox 3 like this:
> > *firefox3/blah/blah/firefox-bin
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Selenium Users" group.
> > To post to this group, send email to seleniu...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>

Message has been deleted

Davina Armstrong

unread,
Jan 29, 2010, 5:48:22 PM1/29/10
to Selenium Users
I modified my test to call setUp(url, "*chrome /home/biit/firefox/
firefox-bin"); which again works from the command line but now I get
the following error running it from a crontab:

"Could not start Selenium session: Failed to start new browser

session: Error while launching browser"

Neha Chachra

unread,
Jan 29, 2010, 6:14:19 PM1/29/10
to seleniu...@googlegroups.com
Hm, try to add this line in your bash script at the top:

export PATH= absolute_path_to_firefox-bin:$PATH

That might work.

-Neha



To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

darrell

unread,
Jan 30, 2010, 5:21:41 PM1/30/10
to Selenium Users
Davina,

When you run the script from the command line all the environment
variables are defined for you according to your login. When you add
the command to crontab, the cron daemon probably runs the command as a
different user. Thus the environment variables are different.

This means that not only the path but other environment variables will
be different. There are a few possible solutions.

Some systems have a command to run a process as a different user. The
command might be something like 'runas'. So if your command line was
'foo fee fum' you would change it to 'runas -u darrell -c "foo fee
fum"' or something like that. You'd have to do some research to see if
your system has such a set up and what the command is.

Other systems have permission settings (chmod). You can change the
permission of an executable and it will run as the user who owns it.
Check the man page on chmod to see if your system uses this method.

Another option is to figure out which user is used to run cron tasks
and update that user's environment to match your own.

Darrell

SiKing

unread,
Jan 30, 2010, 8:31:09 PM1/30/10
to Selenium Users
When you run stuff from cron, your .bashrc (or equivalent) is not
read. You need to source your .bashrc at the start of your script.
Reply all
Reply to author
Forward
0 new messages