It can be incredibly helpful when you're troubleshooting Behat tests to watch the tests execute. It's fairly straightforward to install Selenium locally and watch @javascript tests execute in your browser of choice, a bit more challenging remotely.

Here's how I set up to do that on a remote Ubuntu 14.04 server.

VNC on the Server

  1. Install dependencies:

    sudo apt-get install Xvfb tightvncserver xterm firefox

     
    • Xvfb and xterm are required for Firefox to run on the remote server
    • Firefox is required to run Behat's @javascript tests via Selenium
    • A VNC server, in this case tightvncserver, allows you to install a VNC client locally and watch the remote session.
       
  2. Start the server


    sudo vncserver

  3. Check the port:
    You'll get output like the following. Notice the display designation on
    the end, in this case, the digit 1:


    New 'X' desktop is [servername]:1

    Note: vncserver stays running. To verify the port it is listening on, use the command `sudo lsof -i -P | grep -i "listen"`.

  4. Start Selenium:
    You'll need to specify the display when you start Selenium, and it doesn't hurt to use the command from the Not enough entropy post to be sure it's listening properly.

    DISPLAY=:1 java -jar -Djava.security.egd=file:/dev/./urandom [your/path/to/selenium.jar]

     

VNC on your desktop

  1. Install a VNC Viewer
    I run Ubuntu on the desktop and use TightVNC's viewer:

    sudo apt-get install vncviewer
     
  2. Open an ssh tunnel:

    On your local machine use the following command a terminal to create an ssh tunnel to the server. The last digit of the port corresponds to the display:


    ssh [serveraddress] -L 5901:localhost:5901

    This stays open in its own shell tab.

  3. Run the local vncviewer:

    vncviewer localhost:5901

Deploy Anywhere, Monitor Everything Drupal.

Take the headache out of Drupal security with Tag1 Quo - Drupal Monitoring Made Easy.