DPI of iOS Device?

I am trying to write some tests for a Xamarin.Forms application that runs on iOS and Android operating systems. I have a button on screen that I need to be able to tap, but unfortunately this button for some reason is not returned in the page source to Appium. So, I’m trying to tap on it via the xy coordinates of the button.

Problem is, the location of this button can change but it is relative to another element that I can identify. So I definitely have ways to discover the xy of this button programmatically, but the issues arise when I try to code this test up so that it can run on any device.

Because Android and iOS devices can have a drastically different DPI, the number of pixels that I need offset can vary wildly. Even using a percentage of the screen width doesn’t work reliably because of this difference.

I’m able to easily get the DPI for an Android device and I can use that to do some calculations. However, I’ve not yet been able to find a way to get or calculate the DPI of an iOS device. Has anyone figured out how to get or calculate the DPI of an iOS device?

You could try to retrieve the scale value from mobile: deviceScreenInfo extension

Thanks for the suggestion. I’m unclear though how that would give me the DPI. As I understand that scale is the pixelRatio which can’t really help me determine the DPI. Can you explain a bit more?

So, basically if you want the dpi, you could multiply the scale by 160.