How to automate testing of a mobile domain redirections with jmeter

There are many ways to implement mobile version of your website but easiest and probably cleanest one is to use mobile subdomain.

Once you have your mobile website you want to implement an automated test suite to be able to regression test the functionality after every release. You also want the test suite to be easy to configure and run it against test environment. In perfect world you want the test suite to run as part of the continous integration setup. Jmeter allows for all of that and is free. As a huge fan of jmeter i recommend you download it and play around with it as soon as possible.

In this article I describe how to create a test suite for mobile website redirects, you can also download my jmeter test plan and customise it to test your own websites.

Main use cases for mobile website redirects

My website has a few main use cases:

  • New visitor without cookies, hits any link on the website (from external site or search)
  • Existing visitor viewing our website, clicks around between pages (user has a cookie)
  • User who has a mobile cookie already and decides to view the full version of the website - clicks an override link

Now each of these use cases can be ran from a mobile browser or desktop browser. we also have to support users who click on a link leading to a desktop website as well as to the mobile website (user may go back to search and click on another link).

Jmeter tests to discover mobile devices

I implemented a simple user agent based redirections. I check user agent string and search for substrings like: mobile, phone, android, iphone, ipad and ipod. If user does not have cookies and does not have override parameter in the url i use the user agent based recognition.

To test it i have create a list of user agent strings as user defined variables in jmeter test plan. Then i create a foreach controller for a mobile user agent strings and one for desktop user agents.

In each iteration jmeter picks next user agent string, sets the header and then hits the mobile domain as well as regular domain. Both domains should redirect to the correct URL based on the user agent. We dont know where and how our website is linked to so it is safest to support redirects on both subdomains.

As part of the test we add assertions to make sure that correct cookie is set and correct version of website is shown.

This should take care of all the new visitors who do not have cookies, no matter if they hit the mobile or full site domain.

Cookie based website redirect tests with jmeter

Second test case is to make sure that user with a valid cookie mobile or not will be show the correct version of the site. We can have following scenarios:

  • mobile cookie, mobile user agent, mobile domain
  • mobile cookie, mobile user agent, regular domain
  • mobile cookie, desktop user agent, mobile domain
  • mobile cookie, desktop user agent, regular domain
  • desktop cookie, mobile user agent, mobile domain
  • desktop cookie, mobile user agent, regular domain
  • desktop cookie, desktop user agent, mobile domain
  • desktop cookie, desktop user agent, regular domain

Test plan would look like this:

In all these cases cookie is the most important factor and we want to verify if correct version of the site is shown. I place the cookie manager under each sampler to make sure that tests do not interfere with each other. Assertions are shared across the group so they are placed one level higher in the hierarchy.

See full website link verification with jmeter

Next step is to verify if "see the fill website" link works as expected. On mobile view we display footer with a link that lets user opt out from the mobile version and see the full website.

When user clicks on the link we should issue new cookie so that following clicks would show full version of the site.

No matter what headers or cookies user has we have to set new cookie and show full website.

In this case we only check desktop domain as there is no link leading to the domain subdomain.

In this case we test both combinations of mobile and desktop user agents with mobile cookie, desktop cookies and without cookies.

Finally a deep link test

Just to make sure we have covered all bases I have added a deep link test to make sure that user who hits a deep link to an article will see the same article but on a correct website version.

I have added these tests in separate thread group just to speed up execution.

Download mobile redirects jmeter test plan

If you like the idea behind this test plan please feel free to download my jmeter test plan.

You should be able to customise it easily and use for your own website :)

Comments

Post new comment

Image CAPTCHA