Using Proxies in UI Testing

When testing web browser based software, I often find using a proxy to intercept  the browser calls is a powerful tool that helps me cover all my use cases.  It is also something that I sometimes get questions about. Usually I get questions about why to use proxies, and what proxy to use.

Why use a proxy?

A proxy routes all the calls from the browser (or mobile or desktop application) which gives you the ability to observe the calls, and to manipulate them.

Observing: Observing browser calls is often necessary to perform validations.  For example it may be necessary to validate that values in calls to analytics systems are correct.

Intercepting: This is the really exciting aspect of using a proxy.  One advantage of this is to force negative use cases.  Things like forcing service calls to fail so I can validate our application handles it gracefully.  Another advantage is to mock those requests in order to force special cases, or to force the service calls against the different environment.

Here are some of the proxies that I have used and a (very) brief description.

Chrome DevTools

The Chrome DevTools is not really a proxy, but it does allow observing all the browser traffic and it is quick and easy to use.  It doesn’t give the ability to manipulate that traffic however.

Charles Proxy

The Charles Proxy is a staple that I have used for years.  It is great for interactive use.  You can use it to observe and intercept requests from mobile or desktop applications in addition to web browsers.

Browsermob Proxy

Browsermob Proxy is a very handy proxy when you want something that you can embed within your Java software.  It has great support for intercepting and replacing requests and responses.


WireMock is another great proxy that can also be embedded into Java application code or used standalone.  It has some great features that allow the recording of requests and then play them back later which allows you to disconnect from back end systems.

2 thoughts on “Using Proxies in UI Testing”

  1. Hi Brian, between Browsermob and Wiremock, if you had to embed it in your code to capture and replace responses, do you prefer one over the other for any reason?

    Or can you think of anything which you have found more useful in any of those tools?

    1. I have been using BrowserMob for embeded use. I use WireMock more for stand alone proxies. When I was originally doing the embedded proxy and browser request intercept, WireMock wasn't as much an option. But WireMock is now an impressive piece of software and supports storing responses and has recording options that BrowserMob does not have. If I were starting over, I would probably investigate WireMock first to see if it meets all my needs.

Leave a Reply

Your email address will not be published. Required fields are marked *