Search code examples
pythonubuntuseleniumxvfbpyvirtualdisplay

is it possible to peep what selenium is doing during automated tests?


I perform headless web session tests with selenium (python, ubuntu server 15, firefox), which can last for hours. I do make use of pyvirtualdisplay + xvfb.

My python scripts begin like this:

from pyvirtualdisplay import Display

virtualdisplay = True

if virtualdisplay:
    display = Display(visible=0, size=(1920, 1240))
    display.start()

How is it possible to peep what's goin' on without actually get screenshots, e.g. vnc session?

I tried several solutions, but they didn't work because perhaps they are outdated or too general.


Solution

  • using x11vnc can do the trick. Just add this line to bash script you are using to launch tests:

    x11vnc -q -bg -display $DISPLAY
    

    After that you can connect to your virtual display on default port 5900 (or any other of your choice). Keys -q and -bg forces x11vnc to be quiet and run in background respectively. Of course, you should set up port forwarding for SSH connection:

    ssh -L 5900:localhost:5900 yourhost