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.
Options for Mobile Web Debugging
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.
Debugging Using Vendor Toolsets
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.
Ghostlab: Remote DOM Inspection
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.
See the Pen yymJWG by Vanamco (@vanamco) on CodePen.
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.
I’ve used Ghostlab 1 and 2 for a while now, and let me tell you: it effin rocks \m/.
Matt and his team responded promptly to an issue I had a few weeks ago and helped me resolve it in minutes.
Can’t recommend Ghostlab enough.
We’ve been using Ghostlab at our company and love it. Between remote debugging, not having to use the command line and synchronized scrolling across desktop and mobile, it solves a lot of problems all in one piece of software.
Awesome, totally awesome. Weinre is out. Hate it. jsconsole is in, Ghostlab currently in testing to replace jsconsole.
Thank you for suggesting a tool which is open source, but most importantly does not force you to use Windows or Mac. ;)
It would be really great if that kind of information was in your official documentation though. I looked and couldn’t find any solution to my problem until I got here.
Anyway, Ghostlab is awesome so all is forgiven :)
Great ! very useful!
Looks sweet, too bad it’s not free but hey, looks like it’s worth it.
Wow just tried and it works almost seamlessly with browseemall. I think i will disable my browsersync setup and try it further. Thanks for this info.
That’s exactly what happened to me, I dropped BrowserSync. But BS is still awesome as sh!¡”·t.
Have been using Ghostlab for the last couple of months and I am glad I found it. Makes testing so much faster.
Hi. Does GhostLab work with hybrid apps?
Theoretically it is possible – provided that your framework lets you load the resources over the network (i.e., from the Ghostlab server) instead of from the file system.
E.g., Cordova/iOS: I didn’t try this, but I believe you could replace the initialization of
loadSettingsmethod in CDVViewController.m by Ghostlab’s server address.