diff --git a/src/main/java/io/percy/appium/providers/GenericProvider.java b/src/main/java/io/percy/appium/providers/GenericProvider.java index a02b67e..625bf49 100644 --- a/src/main/java/io/percy/appium/providers/GenericProvider.java +++ b/src/main/java/io/percy/appium/providers/GenericProvider.java @@ -234,7 +234,7 @@ public void getRegionsByLocation(JSONArray elementsArray, List customLoc for (int index = 0; index < customLocations.size(); index++) { try { Region customLocation = customLocations.get(index); - if (customLocation.isValid(width, height)) { + if (customLocation.isValid(height, width)) { String selector = "custom region " + index; JSONObject region = new JSONObject(); JSONObject coordinates = new JSONObject(); diff --git a/src/test/java/io/percy/appium/providers/GenericProviderTest.java b/src/test/java/io/percy/appium/providers/GenericProviderTest.java index dc85416..0ab92db 100644 --- a/src/test/java/io/percy/appium/providers/GenericProviderTest.java +++ b/src/test/java/io/percy/appium/providers/GenericProviderTest.java @@ -233,7 +233,12 @@ public void testGetRegionsByLocation() { customRegion.setBottom(100); customRegion.setLeft(200); customRegion.setRight(250); + // Dimensions are 1080x2160 + Region invaliCustomRegion1 = new Region(2299, 2230, 200, 250); + Region invaliCustomRegion2 = new Region(50, 100, 1070, 1100); customLocations.add(customRegion); + customLocations.add(invaliCustomRegion1); + customLocations.add(invaliCustomRegion2); AndroidMetadata metadata = new AndroidMetadata(androidDriver, "dummy", null, null, null, null); GenericProvider genericProvider = new GenericProvider(androidDriver);