The following a guest post by Andi Dysart and Matthias Christen of Ghostlab. I was pretty impressed when I heard that the newly-released Ghostlab 2 could do this. I think a lot of us developers use Chrome because the DevTools are so good, and it sure would be able to use them in other browsers, even on mobile devices. And why not? Chrome DevTools are a part of Blink, which is open source, right? We just needed a tool to make it happen.
Now while that’s true for desktop browsers, it’s a little more difficult when you try to identify a problem in a browser on a mobile device.
Let’s have a look at what your options are for mobile debugging tools. We’re first going to outline how you can inspect and debug websites on Android and iOS using Google’s and Apple’s respective toolset (we’ve chosen to limit ourselves to these platforms for the sake of briefness). Then, we’ll introduce Ghostlab’s approach to remote inspection and debugging with the help of a simple example.
Goggle’s developer tools allow you to inspect any web page running in Chrome on Android by connecting the Android device (only 4.0 and newer) to your computer via USB. On your computer, you’ll also need Chrome. To set this up, enable USB debugging on the device, and in your computer’s Chrome, browse to `chrome://inspect` to discover the device. After you’ve allowed the desktop access on the device, you can inspect and debug any web page that is viewed in Chrome on the device.
This is possible for iOS as well, Safari to Safari. You also need to connect your device to the computer with USB. In the advanced Safari settings on the device, enable the option “Web Inspector”. Then open Safari on your computer, and in the “Developer” menu, you’ll see a list of iOS devices currently connected to your computer by cable. For each device, you’ll be able to inspect and debug any web page that is being displayed in Safari.
So let’s say that for two popular platforms, there are ways to inspect your website on the device – albeit with limitations. On Android, it won’t work below version 4.0. Also, you can only inspect pages that run in Chrome – if you experience problems in another mobile browser, that won’t be enough. This is similar on iOS, where you are only able to inspect mobile Safari. And of course, you’ll need a Mac to do so.
In addition to these limitations, you basically need a separate toolset for each target platform – one for Safari on iOS, and one for Chrome on Android. Even if you can find a toolset for each of your platforms, you’ll need to set all of them up, figure out how to work with them – and that’s still not taking into consideration that you’ll have to connect each device to your computer with a cable.
Ghostlab (which runs on both Mac and Windows) proxies the site you want to test (either from your local filesystem or a remote URL) and lets any number of clients (browsers or devices) connect to the site at the same time. Then, it will keep all of them in sync – meaning that if you use your desktop browser to do a test run, everything you do (scrolling, link clicking, form filling, etc.) will be replicated on all connected clients.
Once you have Ghostlab running and have started the server by clicking the play button, you can connect your default browser by clicking the rocket button and mobile devices by entering the Ghostlab server URL or using the convenient popup QR barcode.
Now that you’ve got several clients connected, let’s inspect them. On any listed client, you can start inspection by clicking the inspector icon (
Let’s start with DOM inspection. In the elements section, select any DOM element that you’d like to make changes to, and do so; e.g., edit its CSS styles or modify node attributes or texts. If you’ve got synchronized inspection enabled, the modifications you make will be transmitted to all connected clients – if synchronized inspection is disabled, it will only be applied on the client you are currently inspecting.
Here’s a movie showing off how that works:
In the simple example, we’ve got two buttons, one of which will trigger four table cells to be re-coloured, and one of which will cause an error trying to achieve the same task.
Although some of the pain of mobile debugging has gone away with browser-specific tools, there still are limitations, and it requires setup. With Ghostlab, no special setup is required, and it’s easy to get started.