I want to add different behavior to a form based on whether they are on a device (mobile / tablet) vs a desktop computer / laptop. How do I find this information out?

    CommentAdd your comment...

    1 answer


      There are current no Maestro methods to find this out. However you can do this yourself.

      If you only are looking for screen size then I recommend using the window.matchMedia("only screen and (max-width: 760px)") method as it does not look at the userAgent.

      Other methods can be found here:


      Also, you can find out the current browser by using Resource.browserType.

      In Maestro 5.1 you will be able to find out if the device is iOS or Android by using Resource.deviceType


      1. Kamel Bourahla

        Hello Ben,

        The link is interesting, do you know how you can use it on Maestro?


      2. Ben Warner

        Using Modernizr in Maestro is pretty easy:

        1. Build your custom modernizr-custom.js file on their website and download it.
        2. Add a JavaScript library to your form and add the downloaded JS file.
        3. Now in your rule scripts you can use the Modernizr detects, e.g.:
          if (Modernizr.touchevents) 


        However, debate is strong as to how to best determine if a user is on a mobile device or not. For me, I think I'll take a very simple approach and go with something like this:

        var isMobile = navigator.userAgent.match(
                /(iPhone|iPod|iPad|Android|webOS|BlackBerry|IEMobile|Opera Mini)/i)



      3. Ben Warner

        I've added an article to the Knowledge Base on this topic:

      CommentAdd your comment...