@@ -58,7 +58,7 @@ public static ImageLocation findImage(String searchedImageFilePath, String scene
5858 ImageLocation imgLocation = imageFinder .findImage (searchedImageFilePath , sceneImageFilePath , settings .getTolerance ());
5959
6060 if (imgLocation != null ) {
61- Dimension screenSize = getScreenSize (platform );
61+ Dimension screenSize = getScreenSize (platform , sceneImageFilePath );
6262 if (platform .equals (PlatformType .IOS )) {
6363 imgLocation = scaleImageRectangleForIos (screenSize , imgLocation , sceneImageFilePath );
6464 }
@@ -280,19 +280,28 @@ private static void takeIDeviceScreenshot(String screenShotFilePath) throws Exce
280280 }
281281 }
282282
283- private static Dimension getScreenSize (PlatformType platform ) throws Exception {
283+ private static Dimension getScreenSize (PlatformType platform , String sceneImageFilePath ) throws Exception {
284284 if (platform .equals (PlatformType .IOS )) {
285- return getIosScreenSize ();
285+ return getIosScreenSize (sceneImageFilePath );
286286 } else {
287287 return getAndroidScreenSize ();
288288 }
289289 }
290290
291- private static Dimension getIosScreenSize () throws Exception {
291+ private static Dimension getIosScreenSize (String sceneImageFilePath ) throws Exception {
292292 String udid = getIosUdid ();
293293 String productType = getIosProductType (udid );
294- Dimension screenSize = getIosScreenSizePointsFromPropertiesFile (productType );
295- return screenSize ;
294+ try {
295+ Dimension screenSize = getIosScreenSizePointsFromPropertiesFile (productType );
296+ return screenSize ;
297+ } catch (UnsupportedOperationException e ){
298+ logger .warn ("Current device not included in the ios-screen-size.properties-file. Assuming x3 Retina display." );
299+ logger .warn ("Add the devices screen size information to the ios-screen-size.properties-file" );
300+ int screenHeight = (int ) (imageFinder .getSceneHeight (sceneImageFilePath )/3 );
301+ int screenWidth = (int ) (imageFinder .getSceneWidth (sceneImageFilePath )/3 );
302+ Dimension screenSize = new Dimension (screenWidth , screenHeight );
303+ return screenSize ;
304+ }
296305 }
297306
298307 private static String getIosProductType (String udid ) throws IOException , InterruptedException , Exception {
@@ -316,11 +325,11 @@ private static String getIosUdid() throws Exception {
316325 return udid ;
317326 }
318327
319- private static Dimension getIosScreenSizePointsFromPropertiesFile (String productType ) throws Exception {
328+ private static Dimension getIosScreenSizePointsFromPropertiesFile (String productType ) throws UnsupportedOperationException , Exception {
320329 Properties screenSizeProperties = fetchProperties ();
321330 String screenDimensionString = (String ) screenSizeProperties .get (productType );
322331 if (screenDimensionString == null ){
323- throw new Exception ("ios-screen-size.properties is missing entry for: " + productType );
332+ throw new UnsupportedOperationException ("ios-screen-size.properties is missing entry for: " + productType );
324333 }
325334 String screenDimensions [] = screenDimensionString .split (" x " );
326335 if (screenDimensions .length !=2 ){
0 commit comments