mardi 9 octobre 2018

Screenshot doesn't match coordinates and size of element for iOS app

I'm using a Appium methods to take a screenshot and crop a perticular part of that screenshot according to coordinates and size of an element.

The way I do this:

Take a screenshot

This is done with getScreenShotAs() method


Crop out the part of that image

This is done

        image.getSubimage(getElementCoordinateX(element),
                          getElementCoordinateY(element),
                          getElementWidth(element),getElementHeight(element));

        public static int getElementWidth(MobileElement element) {
            return element.getSize().getWidth();
        }
        public static int getElementHeight(MobileElement element) {
            return element.getSize().getHeight();
        }
        public static int getElementCoordinateX(MobileElement element) {
            return element.getLocation().getX();
        }
        public static int getElementCoordinateY(MobileElement element) {
            return element.getLocation().getY();
        }


I tested this approach on Android and it works as intended, but on iOS it crops out totally different part of the screenshot and I'm sure that it's the right element that's being located.

Developers told me that iOS apps work with frames and that I'm probably getting the bounds coordiantes and not the frame's coordinates. Is there a way to make this work as intended?

Aucun commentaire:

Enregistrer un commentaire