Skip to main content

How to Simulate Slow Connections

Intro

With Selenium, you have the luxury of cross browser testing. But what happens when you also need to test how your application behaves on a slow connection?

A Solution

With the help of a proxy server like BrowserMob Proxy we can simulate bandwidth limitations and run our tests to see if they fall down. In order to do this we'll also need to adjust our Selenium's default timeout.

A Brief Primer on BrowserMob ProxyBrowserMob Proxy is a server which sits between your browser and the application you're testing. You connectto it by configuring a browser profile to pass through it. As listed onthe BrowserMob Proxy GitHub page, here are someof the benefits it offers:+ blacklisting and whitelisting certain URL patterns+ simulating various bandwidth and latency+ remapping DNS lookups+ flushing DNS caching+ controlling DNS and request timeouts+ automatic BASIC authorization

NOTE: You can also capture HTTP status codes with it as well. See tip 17 for details on how to do that.

Let's continue with an example.

About The Author

Dave Haeffner is the original writer of Elemental Selenium -- a free, once weekly Selenium tip newsletter that's read by thousands of testing professionals. He also created and maintains the-internet (an open-source web app that's perfect for writing automated tests against).

Dave has helped numerous companies successfully implement automated acceptance testing; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is also an active member of the Selenium project and has spoken at numerous conferences and meetups around the world about automated acceptance testing.

Dave Haeffner profile picture