Friday 17 June 2016

Viewing the remote machine desktop of Linux using VNC

Most of the times, tests are run on the remote Linux machines. We can view the execution on remote Linux machine using virtual desktop. We need below 2 binaries running on the server.
  1. xvfb - Virtual frame buffer - display server that implements X11 display server protocol. It does not show anything on screen. Another option is Xdummy. So in short, xvfb creates the virtual display in memory.
  2. VNC Server - xvnc - Virtual network computing (Virtual display server). RealVNC, x11vnc and TightVNC are other tools that you can use. In short, VNC server allows you to start the server attached to
    display created by xvfb.
  3. On the client side, you need to install VNC client. VNC client connects to the VNC server allowing you to view the virtual display.
Starting the virtual display and VNC server

if [ -z "${DISPLAY}" ]
then
   echo "DISPLAY environment variable is not set"
   exit 1
fi

XVFB_RUNNING=`ps -efa | grep "Xvfb :97" | grep -v grep | cat`
if [ ! -z "${XVFB_RUNNING}" ]
then
   echo Xvfb is running: ${XVFB_RUNNING}
   exit 2
fi
XVNC_RUNNING=`ps -efa | grep "Xvnc" | grep -v grep | cat`
if [ ! -z "${XVNC_RUNNING}" ]
then
   echo Xvnc is running: ${XVNC_RUNNING}
   exit 2
fi


rm -rf /tmp/.X*
/usr/bin/Xvfb :97 -screen 0 1280x1024x24 1>/dev/null 2>&1 &
/usr/bin/vncserver "$DISPLAY" -geometry 1280x1024


Killing all processes with name Xvnc
/usr/bin/killall -q -u `whoami` Xvnc | cat

XVFB also allows you to run the Firefox tests on Linux in headless manner. RealVNC also provides VNC server and clients.

Then from the VNC client we can connect to the VNC server at port say 97 and view the virtual display.


What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors