Debugging Browser-based Tests

Integration tests can be difficult to debug, in particular when running on a remote machine. We recommend two options for debugging your browser-based tests on Scrutinizer.

Save screenshots as artifacts

Each build can generate build artifacts which we will persist when tearing down the VM. This allows you to save screenshots as part of your build, and to view them when your build finishes.

Saving screenshots is a built-in feature in webkit and Selenium, and supported by most test runners:

Simply save the screenshots to the ~/artifacts directory, and we will pick them up automatically.

Watch the display in your own browser

You can view your UI tests right in your browser, when running an SSH debug session.

As soon as the test container is prepared, a Display tab opens on the right side:

view tests in your browser

Interact with the display via VNC

Note: This only works if you are using a driver that controls a real browser like Selenium, but not with headless drivers like phantomjs.

VNC allows you to view and interact with the browser that is running your tests. Setting this up is simple:

Prepare the remote VM

In order to reach the VM, start your build in SSH debug mode so that we can establish an SSH connection.

Next, we set-up a SSH tunnel that forwards the local port 5902 of localhost to port 5902 of the build environment:

ssh -p PORT [email protected]_ADDRESS -L 5902:localhost:5902

Make sure to replace PORT, USER and IP_ADDRESS with the information displayed on the build page.

Last, start the VNC server on the VM:

x11vnc -rfbport 5902

Prepare your local machine

We recommend installing the RealVNC viewer which is available on most platforms, but you can use any VNC viewer basically.

Once installed, we can connect with the viewer to localhost:5902.

Then, you can run your tests on the remote machine and watch your browser via VNC just as if it were running on your local machine.

Note: If you get any warnings about unsecured connections, you can safely ignore these as we are routing the traffic over the SSH tunnel and your VNC viewer is not able to detect that.