Re: Live server tests from cron

2013-08-10 Thread Drew Ferguson
Hi 

I don't know anything about selenium.

However, from what you are describing - trying to run an application from
cron that requires an Xserver - is problematic i.e. there is generally no
Xserver available that can be used so your "DISPLAY=:0.0" essentially has
no effect.

To get round this, you may need to launch an X server whenever your cron
job kicks off. You can do this by creating a virtual X server using Xvfb.
In the past I have used the script xvfb-run to achieve this; this article
pointed the way

http://www.flexthinker.com/2009/09/building-a-flex-project-with-maven-using-hudson-on-centos/

If you think this might be the way to go, feel free to contact me off list
as it has nothing really to do with django.


On Sat, 10 Aug 2013 16:56:32 -0600
Larry Martell  wrote:

> I have some tests that use LiveServerTestCase and selenium. When I run
> them from the command line they work fine. But I want to run them from
> cron. I know I need to use pyvirtualdisplay, but I can't seem to get
> it to work.
> 
> I have this in my test:
> 
> from pyvirtualdisplay import Display
> 
> @classmethod
> def setUpClass(cls):
> #initialize HIDDEN display
> display = Display(visible=0, size=(800, 600))
> display.start()
> 
> cls.selenium = WebDriver()
> super(EventsTableTestLive, cls).setUpClass()
> 
> But it fails with:
> 
> WebDriverException: Message: 'The browser appears to have exited
> before we could connect. The output was: Error: cannot open display:
> :1024\n'
> 
> Where the display number is different each time. Googling this, I saw
> that I needed to add something like this to the script I run from cron
> that invokes the tests:
> 
> export DISPLAY=:0.0
> xhost +
> 
> But that seems to have had no effect at all. This question seems to
> have been asked a lot, but none of the answers I saw on SO or other
> sites worked for me (none of them were using django).
> 
> Anyone here run LiveServerTestCase selenium tests from cron?
> 
> Thanks!
> -larry
> 



-- 
Drew Ferguson

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Live server tests from cron

2013-08-10 Thread Larry Martell
I have some tests that use LiveServerTestCase and selenium. When I run
them from the command line they work fine. But I want to run them from
cron. I know I need to use pyvirtualdisplay, but I can't seem to get
it to work.

I have this in my test:

from pyvirtualdisplay import Display

@classmethod
def setUpClass(cls):
#initialize HIDDEN display
display = Display(visible=0, size=(800, 600))
display.start()

cls.selenium = WebDriver()
super(EventsTableTestLive, cls).setUpClass()

But it fails with:

WebDriverException: Message: 'The browser appears to have exited
before we could connect. The output was: Error: cannot open display:
:1024\n'

Where the display number is different each time. Googling this, I saw
that I needed to add something like this to the script I run from cron
that invokes the tests:

export DISPLAY=:0.0
xhost +

But that seems to have had no effect at all. This question seems to
have been asked a lot, but none of the answers I saw on SO or other
sites worked for me (none of them were using django).

Anyone here run LiveServerTestCase selenium tests from cron?

Thanks!
-larry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.