I have pulled so many automation tricks out of my *&#$ I should have started writing them down years ago. Maybe someone should make a repository of them. Anyway, I was trying to verify that our client's logo exists on particular pages of their mobile app. I reluctantly started going down the dumb path of
Get all the android.widget.ImageView elements and see if size is in the array of possible sizes:
[{'width': 145, 'height': 43}, # tab 4
{'width': 217, 'height': 64}, # galaxy s3
{'width': 217, 'height': 64}, # nexus 4
{'width': 217, 'height': 64}, # nexus 7
{'width': 298, 'height': 88}, # galaxy s5
{'width': 298, 'height': 88}, # note 3
{'width': 298, 'height': 88}, # nexus 5
{'width': 298, 'height': 88}, # htc One
{'width': 348, 'height': 103}, # note 5
{'width': 348, 'height': 103} # nexus 6
]
and then I realized that the height/width ratio should be the same. If it's not, we have an even bigger problem of their logo being stretched in a way that their brand manager is going to have a real problem with...
All these ratios are between 0.2949 .. 0.2965, so I'll just round a little (for future devices) to 0.2945 .. 0.297 which is a .25% margin and hope that no other image falls in this ratio. Should do the trick.