LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   XVFB (https://www.linuxquestions.org/questions/linux-newbie-8/xvfb-873567/)

brownie_cookie 04-07-2011 06:54 AM

XVFB
 
Hi all

I'm running a Linux server and I'm working with Selenium.
so i made a test case with Selenium (to check a website) , i exported it to a java file, and i did actually everything i need to do to get this to work BUT when i run the script like

Code:

./check_selenium.sh -b "http://www.google.com" -c "some.folder.name.Rc" -t "*firefox"
and then i get this error:
Code:

UNKNOWN - some.folder.name.Rc: Got some problems: java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser |;;;;
(btw, i still didn't found the solution of that error...)
but the main thingie is that the test must be done in the background, no need to open a webbrowser and let everything run and than close the webbrowser, i just need it to test the website and give me back some result.
And i've read some articles about how to run it headless, and with XVFB is the one that pops out...

I installed it with
Code:

yum install Xvfb
I've found some code that normally should work
Code:

startx -- `which Xvfb` :1 -screen 0 1024x768x24
but now what?
Can someone help me pls how i should run my testcase of selenium on the background (perhaps with Xvfb?)

theNbomr 04-07-2011 01:23 PM

I've never used Xvfb with startx; normally, I just run it standalone:
Code:

Xvfb :1 -auth /etc/xauth.xvfb -fbdir /tmp &
I have a simple authorization file containing simply 'localhost'. After having launched the Xvfb, you can let it serve X to your applications by setting $DISPLAY accordingly:
Code:

export DISPLAY=localhost:1
The ':1' corresponds with the similar argument to Xvfb

Now, if we want to test it, we can launch some application using it.
Code:

# Use commandline '-display' argument as alternative to setting $DISPLAY
xterm -display localhost:1 &

Since there is no visible display presented by the virtual X server, we don't see anything. However, the virtual display can be viewed as a snapshot, since it is stored on our filesystem as a xwd formatted file. We can view a snapshot of the file with xwud:
Code:

xwud -in /tmp/Xvfb_screen0
--- rod.

brownie_cookie 04-15-2011 01:19 AM

Sorry for the late reply
i tried what you suggested, but after the first command i get the following error:
Code:

[root@monitor2 testmap]# Xvfb :1 -auth /etc/xauth.xvfb -fbdir /tmp &
[1] 14407
[root@monitor2 testmap]# _XSERVTransSocketINETCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running

Fatal server error:
Cannot establish any listening sockets - Make sure an X server isn't already running
unlink: No such file or directory
unlink  failed, errno 2
[1]+  Exit 1                  Xvfb :1 -auth /etc/xauth.xvfb -fbdir /tmp

so he says a x server is already running, how can i see that and how can i kill that proces?

UPDATE:
Nice thing to know is that everything works, so i can use the command like this:
Code:

./check_selenium -c "com.example.tests.login" -b "http://website.com" -t "*firefox"
this works, but as you probably know, he opens a browser, which i don't want !!
So HOW can i do this, without the webbrowser, so i guessed with XVFB, but i don't know how this works (i'm not familiar with that)

Thanks in advance

theNbomr 04-15-2011 08:38 AM

Quote:

Originally Posted by brownie_cookie (Post 4325194)
Sorry for the late reply
i tried what you suggested, but after the first command i get the following error:
Code:

[root@monitor2 testmap]# Xvfb :1 -auth /etc/xauth.xvfb -fbdir /tmp &
[1] 14407
[root@monitor2 testmap]# _XSERVTransSocketINETCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running

Fatal server error:
Cannot establish any listening sockets - Make sure an X server isn't already running
unlink: No such file or directory
unlink  failed, errno 2
[1]+  Exit 1                  Xvfb :1 -auth /etc/xauth.xvfb -fbdir /tmp

so he says a x server is already running, how can i see that and how can i kill that proces?

It is a process, so you can kill it just like any other process. Find the process in the process list, using 'ps', and then send it a kill signal. But, that will probably kill your normal X server. If so, then the better approach would be to simply use a different server number. Change the ":1" everywhere to ":2" and retry. Read the X man page for details. If you still have remnants from your first try using startx, then maybe that is the existing X server. If so, kill it and retry.

--- rod.


All times are GMT -5. The time now is 01:04 AM.