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

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.

Leave a Reply

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