2

Is there a way to determine if the Android device I'm running tests on is Phone or Tablet? Found various answers on this topic from an Android development perspective, but I'm just developing tests and looking for some method from Xamarin.UITest that could tell me this. For the iOS there is a built-in method like app.Device.IsPhone, but I can't seem to find something similar for the Android.

Any ideas?

miskegm
  • 55
  • 1
  • 9

1 Answers1

2

The way that I do it in my tests is check the size of the device see code below:

public bool DeviceIsTablet()
    {
        var screen = app.Query(x => x.Id("content"));
        var height = screen.FirstOrDefault().Rect.Height;
        var width = screen.FirstOrDefault().Rect.Width;
        if (width < 1600 || height > 1850)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
TB14
  • 187
  • 1
  • 15