How to get Device DPI

Hi all
is there any way to get the device DPI values
without running shell ADB commands ?

UIAutomator2 driver stores such information in capabilities along with some other useful device info

Any idea about how to get that info from IOS?

Try getSession endpoint:

An Alternative:
I have some code that does a comparison between WebView pixels and Native View pixels… I am not absolutely sure this gets you hardware DPI but, in my experience using it, I think it does (I would appreciate someone correcting me if I am wrong)


AppiumDriver appDriver = <something passed into the method... can be AndroidDriver or IOSDriver at runtime>

 Set<String> contextNames = ((AppiumDriver) appDriver).getContextHandles();
        for (String contextName : contextNames) {

            if (contextName.contains("NATIVE")) {
                ((AppiumDriver<MobileElement>) appDriver).context(contextName);

double screenWidth = appDriver.manage().window().getSize().getWidth();
double screenHeight = appDriver.manage().window().getSize().getHeight();

Good Luck!

what you need to do if you want to access it from you JAVA code
is to get it from SessionDetails obj in case of IOS and from device caps in case of Android


Good to know. Thanks!